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: update fsevents via chokidar to fix MacOS bug #17938
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.
Holy buckets, thanks for the clear explanation. Could you add comments to the useFsEvents property?
Awesome 🕵! Thanks for creating this great workaround.
packages/gatsby/src/internal-plugins/internal-data-bridge/gatsby-node.js
Outdated
Show resolved
Hide resolved
packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js
Outdated
Show resolved
Hide resolved
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.
Holy buckets, thanks for the clear explanation. Could you add comments to the useFsEvents property?
Awesome 🕵! Thanks for creating this great workaround.
How does this PR change performance on a larger site? |
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
@KyleAMathews I'm very interested in the answer to that question as well. Theoretically, it shouldn't hurt any. Basically, what this does is fallback to polling I think it would have to do with how |
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
@wardpeet Done. Sorry, didn't even think about that. I was just focused on getting it out, so I could go to sleep 😄 |
@Js-Brecht Wow - you worked fast on that! I tested it on my end - it seems to completely fix this error for me. I tested it with both |
@ehowey Do you have any production sites, or sites you're developing that might be more complex that you could test it on? |
Need to stress test it |
To be honest, not really. My "production" sites are pretty bare bones when it comes to the size and complexity of the site. Not in a way that provide any kind of system stress anyways. Maybe I could pull down a larger open source site and do something with that? Got any ideas that might fit the bill? |
Chokidar maintainer here. The performance would definitely be shitty after this change. Be careful. fsevents uses one handler for 100,000 files. When it's disabled, chokidar would use 100,000 handlers. Which will use tons of RAM and CPU. |
@paulmillr good to know, thanks. Perhaps you could weigh in on the cause of the issue, and if there's a potential fix? TBH, I think it would be a better solution for the root of the issue to be addressed than to actually use a band-aid fix like this one. |
Nevermind, I see you have a fix in place already. Excellent! |
Yeah, try chokidar@master — if it doesn't work, please provide more detatils. I've ran your loop and it didn't end, everything was fine. Perhaps it's related to "put disks to sleep" setting on MacOS or something like that. |
Hey guys, sorry it's taking me so long. I've been working overtime on a critical business process @ work. I've updated the PR so that you can opt out of using fsevents, since this still seems to be an issue with the updated version of chokidar. This way, it won't effect everyone, but if anybody is experiencing this issue and they aren't concerned about performance (small site?), they can set I have a little time today, so I'm going to begin work on the reproduction repository, so we can start moving towards an actual resolution. |
There is no need for the env var. use CHOKIDAR_USEPOLLING. |
Sounds like there is high confidence already but I did some runs on my mac to sanity check the disable fsevents workaround flag. No obvious problems with functionality either: 15/15 runs not hanging with |
Even better, @paulmillr; glad you're here, because I completely missed that in the docs. Definitely no reason for our own env var, if there is one that chokidar itself uses to do the same thing. Will save in future maintenance, for sure; less to remember to do if another instance of I'll update this PR later today, and just leave it as an upgrade. It works out, because that's likely what it will be anyway, assuming I can narrow down the issue. |
maybe it would be nice have some docs about this and what this env var solves? |
@muescha I will be removing it. I didn't realize there was an env var for chokidar already existing, so this would just be redundant. Instead of |
i mean documenting this maybe in some new troubleshooting doc? |
@Js-Brecht We could just set the polling to true at the start of gatsby-cli. If we make it opt-in, we probably want to put it in https://www.gatsbyjs.org/docs/debugging/ or something. |
Sure, I can write up a doc for it. I'm hesitant now to make it the default setting, @wardpeet, considering how it could affect some sites. It just feels to me like the most effective/efficient method should be the default, and while there are more than just a couple people experiencing this, it's not really enough to warrant bombing everybody. v3.2.1 seemed to help, some; reduced the frequency, anyway. I think I might be making some headway on a reproduction, too. |
Looks like this is caused by For me it is fixing the issue completely. Would be great if someone else can try it also. Here is how to test it:
|
@RomanHotsiy I got the following error trying access your repo:
Do you need to update the permissions?...EDIT: NVM, just had to change the clone location and it worked, |
Looks to have completely solved it for me too 🎉 Awesome! It didn't work at first but then I realised I had a few nested node_modules/fsevents to copy my fsevents.node file to. This find command that google turned up was useful for listing them all: |
I tested it on the hello-world starter and also on a more complex project I am working on using themes and workspaces. It seems to fix it entirely! You do have to make sure you track down all instances of @Js-Brecht and @RomanHotsiy it was awesome collaborating with you both to track this bug down and I learned some stuff along the way. Kudos to your persistance in figuring this one out. Way beyond what I ever would have gotten to on my own. |
Can you guys drop a list of the packages that are using FYI, you can use yarn resolutions if you want to override the version of Or, I guess, point it to where you built it on your own disk, if he doesn't have it built in his repo. |
chokidar, gatsby, gatsby-page-utils, gatsby-source-filesystem
thanks for the |
Oh, I was thinking they were external dependencies 😆 |
New fsevents is out, so just rebuild your lockfiles - chokidar will auto-use it |
Thanks @paulmillr. @wardpeet |
@Js-Brecht if it's resolved we don't really need to write a doc about it. Thanks for your work and let's close this for now. Thanks everyone for jumping on this thread! <3 |
Description
This is a rather quirky issue, where
gatsby develop
(and likelygatsby build
) will hang at various stages while using MacOS. Most common wassource and transform
, and usually when running plugingatsby-source-filesystem
. It also hangs indev-404-page
,internal-data-bridge
, and others.As it turns out, there is an issue with
chokidar.watch()
on MacOS. It usesfsevents
by default, in an effort to increase speed and reduce cpu load.Disabling
fsevents
has been tested by @ehowey, who was experiencing this issue regularly. It has been shown to result in a successful build. It will also increase the load on the cpu, so for larger sites, there will be a performance impact. Use env varCHOKIDAR_USEPOLLING=1
to disablefsevents
.UPDATE 10/10/19
The issue has been tracked down to a bug in
fsevents
itself. Seems there was a race condition that was causing the thread to hang. Thanks to @RomanHotsiy for his hard work! 🎉 🎉 As soon as the fix has trickled down, we can do updates to fix the problem.See comment here for instructions for testing
UPDATE 10/13/19
fsevents@2.1.1
has been published, which resolves the issue. Just requires updating lockfiles.Related Issues
Fixes #17131