-
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
Loading chunks while a new release is deployed #18866
Comments
We are having a similar issue, although different cause. We are running behind an authentication proxy, and when the users session expires, navigation fails due to ChunkLoadErrors. Is this possible related to a regression from this change?#2996 |
Same issue here. To replicate (as of v2.16.1):
The above steps are what a user would experience if they were navigating a site as a new build was deployed. The user will go to click something and nothing will happen - only a page refresh will fix the issue in those cases. I would be happy to help fix but might need pointing in the right direction as I haven't poked around in the Gatsby code to much. |
/cc @pieh |
I've also got this issue since upgrading |
Having same issues with netlify and AWS Cloudfront. |
gatsby/packages/gatsby/cache-dir/loader.js Line 195 in 90f0401
I guess we don't even need to call I'm not sure navigation should keep comparing hash, instead having this information from the loadPage call.
The e2e test is skipped 🤔
@pieh, Do you need help to move forward ? |
We're seeing this same issue as well. |
This is major bug, which contradicts the main goal of CI/CD flow. |
Can anyone identify a version of Gatsby that doesn't exhibit this bug? Rolling back to Or rather is this an issue with one of Gatsby's dependencies? Sorry, I don't have much more to contribute at this stage apart from questions. |
Strange that the tests were disabled because they were failing, isn't that the idea of tests?? 😅I'd have thought that a regression which breaks a test (disabled or not) would necessitate a pretty hasty hotfix! @pieh I see you're assigned to this one - do you have the context to address it or do you need some help getting to the bottom of it? |
@JustFly1984 we have the issue but don't have |
@johndaskovsky thank you for clarification, this is even worst than I thought. |
Yeah, no |
@Sever1an can you check if you have same issue? |
We're running an e-commerce site with Gatsby on Netlify and have noticed a number of these I wonder if more people are having this issue and simply aren't noticing because they aren't monitoring client errors or don't have a lot of active sessions during deployment. For now, we're watching real-time sessions and deploying at odd hours to avoid the issue but it would be great not to have to worry about it. Minimal Steps to Reproduce
ResultThe link does not function and throws a The output looks similar to this:
|
I think so, yes. We've noticed |
We are also running an e-commerce with Gatsby on Netlify (which is a lovely experience overall i must say!) but we too, have been running into a bunch of not so nice experiences for customers who has been in the middle of the checkout flow, as it relies on the user being navigated between different pages, which breaks when we do a new deploy (and was not built with this issue in mind) Since there are users in the checkout flow basically all the time, there is no 'safe' window where we can do a deploy without putting ourselves in a really bad spot. We've basically had to revert to avoid doing deploys as often, which is obviously a not so nice experience. I'm not sure this is all on Gatsby though, e.g. if Netlify would avoid deleting all old files (ie. the chunks would still be there) on new deploys this wouldn't be an issue i believe? But it feels like Gatsby should have a safe fallback for this? |
We have same issues both on netlify and AWS Cloudfront/S3. |
The only fix I have been able to implement has been to remove all use of gatsby-link and just use anchor tags. Full page reloads are not nice but nothing can be done until this is fixed. |
@GooBall in our case page reload is not acceptable, cos we have authenticated state. and Safari drops cookies for cross-domain requests. |
Our site's design relies heavily on page transitions hence removing |
I've done a bit of investigation into this myself as it's causing a lot of alerts for us when we deploy, due to active user on our website, and sometimes days later, which I assume is users who had opened the site before a deploy and continued to use it some time later like @editkid describes. Here's the PR that I believe introduced this bug: #16686 If you look at the CI logs for this PR, the disabled test in The most recent change to Unfortunately I don't know enough about this side of WebPack or Gatsby to be of much further use, but hopefully this is of some help @pieh
|
Sorry to "at" you @KyleAMathews, but there hasn't been any comment or activity from @pieh on this since it was assigned to him a couple of months ago, so I'm worried it's just flying under the radar because of the "assigned" status. Is there someone else who might be able to check this out? There seems to be a reasonable number of people affected by this, and it's easily and reliably reproducible with the latest version of Gatsby (including any given "starter"). |
Thank you for this! I believe it is working for me. I refactored a few pages on my site and when I clicked a The only caveat is that errors are still logged by Sentry, so I added |
Where is the failing Promise anyway? Can we not perform the fallback in its Something like navigateTo(destination).catch((error) => {
if (error instanceof ChunkLoadError) {
window.location.pathname = destination
} else {
throw error
}
}) |
I don't think we can catch the error because it's happening inside webpack. So |
Has anyone already tested the proposed workound? |
@AlexanderBich It does just what it should. Since we added the workaround to @KyleAMathews This should really be part of every Gatsby installation. |
Seconded |
Yep, it's working for us as well. If this gets added in some default way to gatsby, please update this thread so we can remove our patch. :) |
gatsby-plugin-image still throws chunk errors even after fix. |
I was able to work around this issue by adding this to my webpack config. It forces their dynamic imports into the main app bundle.
|
I think this discussion about |
We're running into this as well on Netlify + Gatsby. Would love to hear from the Gatsby folks if there's any plan to bridge this? |
@KyleAMathews What should be done when the Javascript and CSS step of
|
@Elyx0 — the last error is fine — immutable is preferred as it's faster but must-revalidate is perfectly safe. This should ideally be a warning not an error — the tool isn't smart enough to differentiate between ideal and less-than-ideal One thing that could help is adding #18866 (comment) to your gatsby-browser.js |
…d the app Fix #18866 The error happens when a user loads a page and while they have it open, a new version of the site is deployed. Then when they try to navigate and the Gatsby app tries to load a js chunk, the chunk might no longer exist on the server and so the app crashes.
BTW, I opened up a PR to add my code snippet to the framework #33032 |
…d the app (#33032) Fix gatsbyjs/gatsby#18866 The error happens when a user loads a page and while they have it open, a new version of the site is deployed. Then when they try to navigate and the Gatsby app tries to load a js chunk, the chunk might no longer exist on the server and so the app crashes.
…d the app (#33032) Fix gatsbyjs/gatsby#18866 The error happens when a user loads a page and while they have it open, a new version of the site is deployed. Then when they try to navigate and the Gatsby app tries to load a js chunk, the chunk might no longer exist on the server and so the app crashes.
It would be awesome to backport this to gatsby 3... I know its not supported anymore but having this bug in the last release of it is quite frustrating for devs who are stuck on gatsby 3 for production sites. https://stackoverflow.com/questions/71506592/gatsby-development-server-stops-on-every-syntax-error |
Description
I think there is a structural issue with the lazy loading of page chunks.
I came across various
ChunkLoadError
s in Sentry reports, and just now it happened to me in Chrome, and it happened when I had loaded a page, then deployed a new version (via Netlify), and then tried to navigate to another page without a full page reload: the new deployed chunks have different paths, so the Gatsby Links can't find the ones it knew... throwing 404s and resulting in not being able to navigate!Steps to reproduce
You can easily reproduce this by deploying, going to the website, changing code & deploying again, and then trying to navigate to another page.
Otherwise, let me know and I'll setup a test website.
Expected result
The navigation should always work.
Actual result
Nothing happens when the visitor tries to navigate to another page.
Possible fixes
A fix could be to fallback to normal navigation (full page reload), instead of letting the visitor on the same page without any reaction...
Now, I read on other issues that it's supposed to fail because maybe the user if offline and we can't detect it: I disagree, there is a difference between a failed fetch because of network issues) and a 404, and it can be detected in Javascript (and maybe use NavigatorOnLine if available, too).
Environment
Related issues
#11194
#2954
The text was updated successfully, but these errors were encountered: