-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby-plugin-sharp): catch errors when writing base64 images #28614
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that we're now catching this one but it makes me wonder what other errors ought to be trapped that currently are not.
Yeah, more generic trapping makes sense to me. I'm not familiar enough with plugin-sharp's history over the past year or so to know what's been tried/considered. |
… object] from showing up in messages
@@ -1,6 +1,10 @@ | |||
const reportError = (message, err, reporter) => { | |||
if (reporter) { | |||
reporter.error(message, err) | |||
reporter.error({ | |||
id: `gatsby-plugin-sharp-20000`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this, messages show up in the console looking like: ERROR [object Object] ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like reporter.error
broke the old-skool way of sending errors?
This could also fix #28203 and [ch19324], but may need to be moved elsewhere to make it work if the error is in another sharp operation. |
@KyleAMathews this is not really fixing the issue, this is working around it. The root problem is here gatsby/packages/gatsby-cli/src/reporter/reporter.ts Lines 128 to 130 in 4cfc0bb
|
Co-authored-by: Matt Kane <[email protected]>
@wardpeet thanks for the pointer. I assumed it'd gotten broken somewhere in there but didn't have context. |
But +1 for structured logs 👍 |
@ascorbic what need moved? |
@KyleAMathews The error handler. This only catches one specific sharp operation, and other operations would likely have the same error which could be uncaught if there was no base64 image |
I mean the one you just added! |
Oh haha I see. I thought there was a generic error handler. Yeah I'll do a quick scan through other read/write calls in plugin-sharp to see if there's any others we've missed. |
One good test would be to see what happens in your test site if you remove the base64 query. Does it bail elsewhere? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with everyone's comments but we can iterate on that. Shipping this now since it is valuable by itself and unblocks one of my broken builds.
Thank you @KyleAMathews 🤗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving again after fixing a formatting issue
This is out on the |
Identified a few other places where we don't appear to trap sharp errors #28640 |
…8614) Co-authored-by: Matt Kane <[email protected]> Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Sidhartha Chatterjee <[email protected]> (cherry picked from commit 02860da)
…8614) (#28659) Co-authored-by: Matt Kane <[email protected]> Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Sidhartha Chatterjee <[email protected]> (cherry picked from commit 02860da) Co-authored-by: Kyle Mathews <[email protected]>
Published in |
…tsbyjs#28614) Co-authored-by: Matt Kane <[email protected]> Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Sidhartha Chatterjee <[email protected]>
Possibly fixes #24774 (comment)
We caught read errors for images but not write errors.
New error: