-
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
Errors when processing large(ish) numbers of images with gatsby-plugin-sharp #6291
Comments
Hmm that's not a lot of info to go on.. can you post an example repo that creates the error you're seeing? |
Had the same issue. Doing a manual |
I can confirm this bug. In my case it started happening, when I added some large images, 5mb or more. |
I had the same problem; Using an older version for gatsby-transformer-sharp (2.1.1) and gatsby-plugin-sharp (2.0.5) fixed it for me. Maybe if there is any debuggers, this might be an additional information. Note that I also have a lot of images on my build. |
@m-allanson I've started working on a repro here: https://github.com/jp887/gatsby-issue6291-repro I'm building the project on CircleCI so build outputs can be inspected without having to run the project locally. The most recent build reproduced the issue: https://circleci.com/gh/jp887/gatsby-issue6291-repro/3 |
@jp887 would you mind trying to take a build on your repro with these gatsby-transformer-sharp (2.1.1) gatsby-plugin-sharp (2.0.5) exact versions, on a new branch maybe? I have downgraded to these versions, and I have taken more than 10 successful builds since. |
@btk OK done. Builds on the 'downgraded' branch can be found here: https://circleci.com/gh/jp887/workflows/gatsby-issue6291-repro/tree/downgraded |
Seems it's still reproducing the issue on the new downgraded branch: https://circleci.com/gh/jp887/gatsby-issue6291-repro/4 |
@TylerBarnes ohhh the dreaded segmentation fault error, it brings me back to when i was using c language as a development tool. That looks like that somewhere deep down in the execution of that plugin, it's trying to allocate memory where's not allowed and it was not deallocated and trying to retrieve something that is not allowed. That is not a gatsby plugin issue per se, more like the underlying vips/sharp, the one written in c. |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! Thanks for being a part of the Gatsby community! 💪💜 |
I am having the same issue at the same build step. My plugin versions are:
|
I seem to have encountered this issue as well. I'll add more to this thread if I discover any additional clues. |
Also... I haven't been able to figure out how to apply the "not stale" label to this issue. I'm guessing that I need to be granted a permission? In either case: the issue does appears to be somewhat random. I just reran the same build without encountering the problem this time. (In both cases, I cleared all cached files before starting the build) |
@briandamaged added it for you. |
@btk : Thx! So far, the issue has not reoccurred. |
I still see this when build by nelify:
It randomly happens using exactly the same git revision: See http://filez.foxel.org/4dec3e172673 for version Information. |
This seems to be unrelated and dos not lead to segfaults / failed builds (same repository):
|
Regarding the segfaults I have found this in the
So far locally I haven't seen any segfaults after commenting out |
That would make sense. I've only seen this on sites with a lot of images and then it's still rare on those sites. Maybe once every 20 - 30 builds. |
@mdornseif @TylerBarnes Thanks for the discovery! I went ahead and opened a PR, removing the lines: #11925 😌 |
Thank you so much for the awesome finds @mdornseif & the PR @niklasravnsborg. 😄 I am also running into these |
Something else we could do to improve stability is to move Sharp to a child process as if it crashes, we could just restart it. |
That would be a cool approach, I like it! 👍 Despite this probably slowing down a build or two, I think that this would definitely satisfy a majority of the folks who run into this issue. 😄 |
Fwiw, I can repro the warning outputs in the new version |
Yes, I saw your comments in the above mentioned sharp issue. Good work, sad it didn't pay off. I don't quite understand your comment about the node version. Is that version related to this issue somehow? I'm running |
@ehannes no, I was able to repro in v10 as well. The comment is about the nodejs EOL cycle. In 2020 nodejs v8 reached end of life ("EOL"), meaning it won't get any more patches and fixes and people should move to node 10, which is the next long term support ("LTS") release version. So this month many packages are bumping their minimum required nodejs version to >=10, sharp being no exception. Gatsby will do so as well but we're taking a little longer to allow people to make the transition outside of the busy December month that it would otherwise have been. Hence, currently we couldn't bump the sharp version because then people on node8 (which we claim is the minimum version we support) would get node version errors when installing. (This can be worked around, I don't think we need to). That said, the new sharp version should be more stable as a few bugs related to this issue were found and fixed. Just, apparently, not all of them. |
I'm wondering if people still see this issue on gatsby-plugin-sharp@2.4.3. We have reduced memory usage of the sharp plugin itself. |
Keep in mind that the segfault was a real race condition problem that was only exposed by high pressure. It was not about memory. |
Still experiencing this issue as of 300-ish images processed into 1800 thumbnails of different sizes will usually fail once or twice (sometimes more) before succeeding. It always succeeds eventually. So I just |
@pvdz any updates on this issue? Still have massive problems with this... |
@ehannes A new version of Sharp was released (with new binary) that is supposed to fix some-if-not-all of these problems. Unfortunately it is released with a minimal nodejs version of 10 (due to EOL of node 8) and Gatsby can not bump the minimal to node 10 right now (but soon...). Meaning we can't bump Sharp at the moment to make use of these improvements. Of course, you can try to install it locally. I haven't had a chance yet to verify the latest release, which is on my todo-list for this week. |
@pvdz I thought this bug was still present in the new Sharp version. You wrote this a month ago:
|
@ehannes yeah, and that was reported upstream, and I think there was a new release about a week ago (or two weeks?). I haven't had time to investigate. We (Gatsby) had a meetup in the US last week. No worky worky in the US for us EU people. Just haven't gotten around to it beyond that, will try to report back this week. As for the node10 concern; the problem I mentioned is not so much the repro but rather that if we bump to the new Sharp version (0.24+) in Gatsby then about 5% of our users will have installation problems because they are still on Node 8 and npm/yarn will block installation due to Sharp requiring 10+. Fwiw, in the end the problem (of this issue) a race condition in the binary used by the Sharp library. It is made more likely by high pressure in the rest of the system but it can happen at any time for anyone. If you want to help out feel free to look at lovell/sharp#1986 and help out. Gatsby should be able to cut over to Node 10 "soon", but I have no exact timeframe on what "soon" is. |
It looks like the next release of Sharp (0.25.0, not yet published) will fix these issues. So it looks like that will mitigate this problem. I was able to generate 30k thumbs without signs of the issue (where before the problem would generally repro between 3k and 6k images processed). Will keep this open until Gatsby can ship the new, fixed, version. But please go ahead and test the |
Can confirm after forcing my project to use Sharp on the yield branch, I am no longer experiencing segfaults with image processing. Previously, I would experience them almost every build, multiple times. THANK YOU SO MUCH! 🥳 |
I can also confirm that the latest version of Sharp is finally solving my build problems! By the way, 0.25.0 is now published, as well as 0.25.1. So grateful for this fix! Thanks for your hard work @pvdz! |
Same here! So excited to see this fixed. Amazing job @pvdz |
Sharp has been bumped by #22432 and that means this issue should now be closed. Please report back if you have Sharp related segfaults or see warning messages that have been reported in this thread. This change has been published in the following packages:
For any other Sharp related problems or questions, please open a new issue. Thanks! |
Per GitHub issue: gatsbyjs/gatsby#6291 (comment)
I am still having occasional segfaults using gatsby-transformer-sharp@2.4.1
|
The issue is still happening with the latest version of gatsby sharp: My website has a lot of pages/images and it's seems impossible to get a build done using Anyone facing the same problem when trying to deploy/build large websites/ lots of images on netlify? |
Quick update: I've tried to deploy my websites using Gatsby Cloud, Vercel, and Netlify and all of them complain about the same error. ( I have updated all plugins and gatsby to the latest version and it's really hard to get a build running at the moment. The only place that the build would run fine it's on my laptop which has 32GB of RAM. I was wondering if gatsby it's not suitable for huge projects with a lot of pages and images? I have already contacted the Gatsby Cloud support and will post updates here! |
Just wanted to add that I'm seeing the same thing on GitHub Actions as well. @lucashfreitas did you happen to get any answers from Gatsby Cloud support? |
Hey @twhitson , I reached out to gatsby cloud support and they have found the problem. Some of the plugins that I had on my project were using a outdated version of sharp library, so the quickest solution is to change the following: upgrade gatsby-plugin-sharp upgrade gatsby-transformer-sharp set resolution for sharp to "0.26.3" To set the resolutions, you can add this entry to your package.json: "resolutions": { Hope it helps! |
Thank you so much @lucashfreitas that was it! I had to set my resolution directly to |
Thanks @lucashfreitas I was seeing exactly the same issue on Azure Static Web apps. Adding the following lines to my "resolutions": {
"sharp": "^0.27.1"
}, |
Description
I'm processing around 1500 images with gatsby-plugin-sharp/gatsby-transformer-sharp and GraphQL, to display with gatsby-image as per this page in the docs.
For smaller numbers of images I have had no issues, but now that I'm processing 1500 images the build randomly fails with the following error:
This happens during the "Generating image thumbnails" step in the build process and it occurs apparently randomly (sometimes 10% of the way through the images, sometimes at 80%, sometimes not at all). Therefore I do not believe it is caused by a "faulty image".
The text was updated successfully, but these errors were encountered: