-
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-source-filesystem
Race Issue copy
ing Files
#27984
Comments
We can also add |
Oh, that wouldn't work if those operations are triggered by different plugins. Then I guess |
We are also seeing the same symptoms with plugin gatsby-rehype-inline-images for about 2 - 3 weeks now. This plugin also sources in a lot of images with the Maybe the |
We have also been experiencing similar problems for about 2-3 weeks now. Our project has a lot of images and using |
@pieh: I could send in a PR for the |
Please, open pull request and do mention me there |
We just published |
That would be ideal approach and something that we will try to move to in the future (probably by providing some abstraction on top of |
That's true, but on the one hand using just |
I did mention
Because of all of the above we want to be able provide comprehensive solution for all those issues in single go so the plugin maintainers would have single migration to do and not force them to do many small incremental updates that also impact users of plugins because compatibility would also be very confusing for users (in cases maintainers decide to not handle backward compatibility and instead bump minimal supported |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
This has been fixed, and released via #28176, and seems to be working well for me. Closing the issue. Thanks! |
Description
This issue is a somewhat "hard-ish to reproduce, but seems clear to explain" issue with
gatsby-source-filesystem
when repeatedly copying the same file many times as part of a build. I think the logs exhibit the issue clearly enough to make sense of it though.I'm using gatsby-remark-relative-images to collect the images. The pages have references to an "OS/platform" (macos, linux, windows), with an icon used for each. As a result, I end up with a lot of operations for
gatsby-source-filesystem
to process on the same images.The core of the issue is: Gatsby will synchronously check if a file exists, and then asynchronously perform the file copy (ref). Occasionally it gets into a state where the
existsSync()
is false, so it tries to copy in parallel with another queued task, and it will fail with a fairly vague error about a file not existing.Steps to reproduce
gatsby-source-filesystem
to copyExpected result
Build should should succeed, and only attempt to copy file once.
Actual result
The build fails with a fairly vague error about the file not existing:
I added some logging locally to gatsby-source-filesystem/src/extend-file-node.js to show when it's processing files, and dump more context when there's an error.
The smoking gun, for me, is at the end where a repeated call to
fs.existsSync(publicPath)
shows that the file does exist, despite the copy operation failing.Workarounds
{ overwrite: false, errorOnExist: false }
to thefs.copy
options seems to fix the issue for me. Potentially this is still vulnerable to race issues depending on the internals offs-extra
, as it's performing a few async checks internally.fs.copySync
also fixes the issue for me, and since it will only be called once per file, I think it's a safer fallback option. I'm not seeing any performance regressions personally, but potentially large projects might? Not sure.Environment
The text was updated successfully, but these errors were encountered: