-
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 doesn't always refresh changes #27609
Comments
Oh, I see you've already followed my advice: #26580 (comment) 😄 We need some way to reproduce it to move forward. Does it happen for you on any project, including our blog starter? If not, please provide a minimal reproduction and we'll be able to take another look. |
Yes, I can reproduce it with blog starter. Typing something in index.js, saving quickly twice (cmd-S), making a change, saving quickly twice; doing this a few times and you'll see that the change isn't shown on the page. |
I also reversed blog starter to a commit that had a version later than v2.24.0 (v2.23.12) and I can't reproduce the issue there. Clearly something changed in the refresh mechanism after v2.24.0 and made it unreliable. @vladar Is there anything else I can do to help with this issue getting fixed? Or am I forever stuck with v2.24.0... 😞 |
I tried to reproduce it with the latest gatsby version and also on Do you have Dropbox or other similar tools installed in the same folder where your gatsby site is located? Maybe some file watchers in IDE or other tools? |
Also, can you bisect a specific version where this problem was introduced for you? The 2.23.12 - 2.24.0 range has too many changes. We need to narrow it down. |
I don't have Dropbox or any other file sharing apps using code files. In my project I have watchers that built the library (Rollup and TypeScript in watch mode). Sorry for not being clear about the version. 2.24.9 works, 2.24.10 does not. |
Then it sounds very similar to #26192 Have you tried upgrading to |
Tried 2.24.57, same thing, does not reload. |
It feels like there's something little different in 2.24.57. After I edited a component in my library, I did get it reload by editing a Gatsby page where the component is imported. Sometimes it works, sometimes it doesn't, sometimes the whole reloading seems to freeze, and I have to restart Gatsby. |
But can you reproduce the problem on the blog starter with |
https://github.com/tu4mo/gatsby-reload-issue
In a another terminal:
With v2.24.57 I rarely get to last update. Running it a few times and the page stops responding. With v2.24.0 it works. You might need to increase the amount of components "created" and decrease the sleep. |
Thank you so much for reproduction! 💜 I definitely see how develop is getting stuck eventually. Also in the given version range - #25815 looks like a primary suspect. Investigating this. |
So one potential problem is here: gatsby/packages/gatsby/src/state-machines/develop/index.ts Lines 189 to 195 in 441263e
We call One possible hint - somehow webpack stops calling
So the next step is to dive deep into |
OK. I think I've found the issue. This PR should fix it (hopefully): #28237 |
Published in |
Tested, and it's better as in it doesn't crash anymore. But it still fails refreshing most of the time :( Tried editing a Badge component in my library 4 times. Here is the browser log.
Component didn't update.
Component updated.
Component didn't update. At that time I also noticed this in terminal, not sure if related:
Component didn't update. Gave up after that. |
I also see this in the terminal 4 times:
So Gatsby seems to pick up the change, but the rebuild times are much shorter. |
I also updated Gatsby in https://github.com/tu4mo/gatsby-reload-issue and I can still reproduce this emulating multiple component updates. |
@vladar Maybe you could re-open this issue? |
Sorry but it didn't. Still reproducible with |
There was another issue with webpack v5 which is hopefully fixed by #30193. Can you try again with |
Yeah, there were actually several underlying issues. And one was a race condition that was not that easy to repro. Can you please try again with I've tried an alternative approach there: synchronizing with webpack events properly and not relying on webpack working correctly with any sequence of |
I couldn't reproduce anymore with On a larger scale, in my real app, I'm still having the old behavior though 😕. Here's a log of making changes in a Gatsby page. It reloaded changes a couple of times, but most of the times it didn't (those <1000ms rebuilds). |
I suspected that there are several distinct issues there. Can you try again with |
Definitely not reliable as v2.24.9 but this version seems to work almost everytime on my real project. I did get the same error as in #27609 (comment) after a few edits thought. |
Opened an issue for the first bug in the webpack repo: webpack/webpack#12882 Still need to find a good repro for the second bug (edit: second issue: webpack/webpack#12898). |
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! 💪💜 |
Not stale. |
Yeah this is still an issue for me |
Does this issue have anything to do with the behavior of Gatsby not knowing about any of the types it should infer from gatsby-node queries until I hit the __refresh endpoint? |
Have you tried it? Maybe remove |
Yes, I tried it. I have another issue with Gatsby v3 so I haven't yet been able to completely switch to v3, but regarding this issue things are looking good 🎉 |
In my case the naming of components have caused the issue |
I suggest opening a new issue. This particular issue that I had has been resolved in webpack. Closing this. |
Extra special thanks to @vladar for sticking with me through this! |
I just want to echo @pbxr250 comment: I was running into a bunch of issues related to hot module reloading, and it was only in a single component. Basically, my first change to either the CSS or JS would show in the browser, but all following edits would not. There were no warnings or errors in the console. I finally figured out it was because of a camel-case problem. My component was named |
@runemadsen camel-case solution worked for me. When I switched branches, one of my file names had more than one uppercase characters in a row. I had to fix the file name. |
Thanks, this was the issue in my case. I named the file with capital first and then was importing that component using all lowercase. Suggestion: Maybe make import checks case-sensitive? |
Description
Gatsby sometimes fails to reload changed components.
Issue can be reproduced after version v2.24.9, so something changed between 2.24.9-2.24.10.
Steps to reproduce
https://github.com/tu4mo/gatsby-reload-issue
Run (multiple times if needed) in a another terminal:
Expected result
The scripts rewrites 10 components with current timestamp. All changed components are hot reloaded.
Actual result
Some, all or none of the components are updated, inconsistently.
Environment
The text was updated successfully, but these errors were encountered: