-
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
Gatsby develop build fails when transforming images with sharp #26857
Comments
Update: I created a repository to reproduce this bug locally or if preferred, a sandbox |
It seems a lot of websites have been experiencing build failures after the Try specifying specific versions of these two plugins, namely If it resolves your build failure, then we've discovered another place where the sharp dependency upgrade is causing issues. |
@sandren I downgraded my dependencies to what you suggested, but the result was the same, so it seems like this issue is unrelated to the issues happening on the latest version of the plugins. |
I could reproduce this with your example, thanks! 👍 And can confirm that changing this line from:
To: pipeline = sharp(file, { failOnError: false }) Indeed makes the build succeed. Instead of exiting the process sharp throws this error which is then displayed in the console as GraphQL error. Also, the @wardpeet Do you see any pitfalls if we add this change? P.S. One missing step for the repro is to actually run a GraphQL query containing sharp transforms, e.g.: {
allImageSharp {
nodes {
id
parent {
... on File {
absolutePath
}
}
fluid {
base64
}
}
}
} |
Any update on this? I would like to see a solution merged in soon. I'd be happy to open up a PR with that single line change if it's all that is needed. I'm not too familiar with other parts of the plugin, so I'm unsure if it would affect anything else. |
We are happy to accept a PR! But this will be a breaking change (as now the build that was failing previously can pass unexpectedly). So it will require a major bump for the plugin. Edit: we can expose |
Great! I'll take another look at the contributing docs on the Gatsby site and open up a PR. And yes, I believe that exposing it as a plugin option instead is a great idea! |
Description
gatsby develop
fails when transforming images withgatsby-transformer-sharp
/gatsby-plugin-sharp
with error:Likely that the error is related to incorrectly encoded Samsung JPEGs per this issue in the
sharp
repository. If thesharp
plugins for Gatsby allowed the passing of an option forfailOnError: false
(as suggested in the issue), that might be enough to resolve this error. Or perhaps instead of that specific option, allowing the passing through of an object with any of the acceptable options as outlined in thesharp
docs.Steps to reproduce
This bug is very specific to sourcing and then transforming images taken on certain Samsung devices so reproducing might be difficult unfortunately. [Edit: see comment below]
Here are details on my setup:
I created a new Gatsby site with the using-gatsby-source-wordpress-experimental starter made by Tyler Barnes.
I set up the appropriate plugins.
I ran
gatsby develop
.All images were sourced correctly and stored locally. After sourcing, images were being transformed and kept failing when reaching images photographed with a Samsung Galaxy S7.
Expected result
It was expected that all successfully sourced images would then be successfully transformed for use with Gatsby Image
Actual result
Images from Samsung devices failed transformation and subsequently ended the development build.
Notes on troubleshooting
When I was trying to solve this issue myself, I was hoping that either
gatsby-plugin-sharp
orgatsby-transformer-sharp
would have the ability to pass through more options. I saw that the specific option I needed (and referenced in thesharp
repo linked above) was not one of the ones I could pass, so I decided to directly manipulate the media that was causing an issue.In my media library, it was a total of 5 images that needed to be re-encoded (by importing into Photoshop, then re-exported as a JPEG). This worked for my site, but it did not seem to be a scalable option. Unless this is fixed in the
sharp
plugins, I will need to do the same for my production site.It's a very specific issue, but I'd rather not have a site with thousands of images crash on a development build because of a single image.
Also, I did a small non-comprehensive test by editing the
gatsby-plugin-sharp/src/process-file.js
file and changing line 83 to be:pipeline = sharp(file, { failOnError: false });
. This also removed the error for my development build allowing it continue without crashing. The image itself was inaccessible bylocalFile.childImageSharp.fluid
but I'd rather have that than not even being able to work on the site withgatsby develop
, especially since I do receive a GraphQL error in my terminal and I'm not unaware of a broken image.Environment
The text was updated successfully, but these errors were encountered: