-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Auto reload page when chunk assets are not found #14594
Comments
Hi @pi0 , it's great!
I see your train of thought is somewhat similar to mine in 6553. However, the effect of that code is not good, because the user will first see the outdated interface, and then refresh for 1 second to show the latest interface. |
I hope to raise the priority of this function, For any enterprise adopting nuxt in the production environment, they does not want to see a page with all styles lost when the user opens the browser for the first time after each new deployment. |
Hey, any news on this or perhaps a temporary workaround? Vercel in particular is annoying as they seemingly don't store old chunks at all which results in them being interpreted as function calls... |
I'm so glad this has come up again! I didn't realize it had been mentioned before because I've actually just discovered this issue and it has caused a huge pain for me and my users. Getting some eyes on this issue would be hugely appreciated 🙏 |
Hey guys, I just wanted to check in on this. Is there any way to expedite a solution (or even a workaround)? Thank you very much 🙏 |
Hey guys, for my use case the following solution is working, hoping for a better and offical way to do this sooner.
|
@shiva-prasad-reddy where do you put that? I'm trying with your code but no luck yet |
@jmverges In app.vue |
thanks @shiva-prasad-reddy it is halfworking now for me. |
Which rendering mode are you using ? |
Thank you @shiva-prasad-reddy !
EDIT: I've added calling of already existing error handlers |
@shiva-prasad-reddy Client Side Rendering Only @toooni I put your plugin in place but I don't get it triggered I'm doing npm run build && nuxi preview then I access to the page and I can navigate then I do npm run build && nuxi preview again and I can navigate to the pages that I already visited but when I click a link that I didn't visit I don't get any error or anything just silently fails. Any clue here? |
@jmverges Also nothing in your browser console? Are you using an errorHandler somewhere else? I've realized that setting the errorHandler without calling the already set errorHandler might not be a good idea. I've added this in my code- But you might have someplace else which overwrites |
@toooni I can't find what is overwritting it but probably some 3rd party it is |
I used the solution by @shiva-prasad-reddy and it works. Thanks a lot! I hope Nuxt 3 will soon handle this out of the box, because now the default behavior is that Nuxt apps can easily end up in an unrecoverable crashed state without any feedback to the user. |
It will be good to have information on which NuxtLink was clicked and then redirect to this URL when error occurs. |
@danielroe thanks for pointing me to this issue! :) I mean this with all due respect, but how is this issue just a "p2-nice-to-have"? If I can't employ a CI/CD flow on a heavy traffic site with nuxt3 without worrying about this sort of issue that is a fairly large discrepancy between something baked into nuxt2 that's not present in nuxt3 and was not mentioned anywhere clearly in the documentation then why is this not a larger/greater priority issue? Perhaps I'm missing something very obvious here, but I'm just curious. |
The label is a triaging system for bugs, so all enhancements are marked as p2. That doesn't reflect where an issue falls on our roadmap. |
Ok thank you for the clarification. :) On a side note, I've really loved working with nuxt3 and despite this major issue I'm running into, I've found it a joy to develop with. |
Hello Developers, I have a question, how are u using loading, during fetch data, methods:{ I am using like this but loading was false during fetching data, in nuxt3 |
I keep old hashes on the CDN living for some time, but use a custom Nuxt module that detects app update and shows a notification suggesting to reload the page. I have been using this approach for years (even since pre-bridge Nuxt 2) privately. Today I published the module as a reusable npm package: nuxt-update. Hope someone finds it useful, too. ✌️ |
Posting for anyone who finds this via Google. I've not opened a new issue because the on going work to add hooks like I find that if I hammer at the refresh and cancel icons in my browser, I can reproduce similar errors, e.g. In that case Nuxt bombs out and ends up on my custom error page. It doesn't reload,. However you can spot the error in |
Does it work with nuxt 2? |
So if I hook into the nuxt/packages/nuxt/src/app/plugins/chunk-reload.client.ts Lines 28 to 32 in 24c5af3
If this isn't the case, what's the recommended way to handle chunk errors from lazy loaded components? |
It seems that this hook will be called on page chunk error too. How would I differentiate between lazy loaded components and pages? |
@nandi95 Would you open a new issue with some suggestions or a reproduction if you're encountering a bug or something you can't achieve with the current approach? |
I'm getting this error as well. And happens randomly, the error is not gone after hard reload. And it's the same in different browsers. It gets fixed after I make a different commit and deploy again. Any ideas? |
@gurgenhakobyan please refer to the comment above yours |
References: #14591
We had this feature in Nuxt 2. Basically what happens is with a new deployment, hashes of old js chunks will be changed. And if users already loaded the page with manifest and chunks of the last deployment, they fail when navigating on client-side that tries to load dynamic chunks.
There are several ways to resolve this issue but probably the safest and easiest, is that same as Nuxt 2 we make use of a global error handler that identifies such errors and reload pages. (Note for implementation: We should set a LocalStorage key to avoid infinity page reloads)
Bonus: We could new offer a new
nuxtApp
hook such asapp:chunkError
that allows graceful HMR alike handling by end-user.The text was updated successfully, but these errors were encountered: