Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

404 Pages whenever I deploy a new build of my site—HELP! #94

Open
jastaffen opened this issue Feb 11, 2023 · 7 comments
Open

404 Pages whenever I deploy a new build of my site—HELP! #94

jastaffen opened this issue Feb 11, 2023 · 7 comments

Comments

@jastaffen
Copy link

Hi there, I'm currently using nuxt-pwa-module for a fairly large website I built using nuxt3 and I'm experiencing an issue that I've only been able to see in production via my log drains. I never actually explicitly set pwa.workbox.enabled and I believe it defaults to enabled if that is the case, but I am noticing that whenever I deploy a new version of my site, I am seeing tons of 404s in my log drains for just the build files themselves (i.e. /_nuxt/useTracking.3ab57097.js). Could this be attributed to the service worker? If so, how can I recache or reset it when a new deployment is made? Alternatively, if I wanted to just disabled the service worker entirely, would setting pwa.workbox.enabled to false entirely clear the service worker from users as they navigate to the site? Would there be anything I should be concerned about in the event that I do decide to disable the service worker?

I know this is long winded. Please help if you can ! :)

@jastaffen jastaffen changed the title 404 Pages whenever I deploy a new build of my site—Question 404 Pages whenever I deploy a new build of my site—HELP! Feb 11, 2023
@jastaffen
Copy link
Author

@kevinmarrec any ideas here?

@kevinmarrec
Copy link
Owner

Hi @jastaffen , we would need to compare files between deployments I guess, I think it's indeed related to the service worker caching assets, but it's hard to debug.

If you disable Service Worker with pwa.workbox.enabled: false, your app won't be able to be installable anymore.

I think I have many improvements to provide around the default service worker to fix some issues, but my Workbox knowledge is limited, I'll need to dive more into it, along the documentation of this module.

If anyone want to have some try on their own regarding custom service worker, there's a pwa.workbox.templatePath option mentioned in https://github.com/kevinmarrec/nuxt-pwa-module#configuration.

@kevinmarrec
Copy link
Owner

I think we should find a way to reproduce it locally by running nuxi build & nuxi preview to simulate production build on localhost with Service Worker.

@jastaffen
Copy link
Author

Hi @kevinmarrec thank you for your in depth reply! I've come to realize that this issue is probably 2-pronged. One is that vite throws an error when it's unable to find a chunk that used to exist as part of a build and nuxt3 is not seamlessly catching those errors and updating the chunk asset (which is what happened under the hood in nuxt 3 [https://github.com/nuxt/nuxt/issues/14594]. The other probably does have to do with workbox's powerful caching mechanisms.

If I were to set pwa.workbox.enabled: false, are you saying that that would break the website or would it unregister the service worker and also mean that the website would no longer be installable on people's local devices? I definitely know less than you about workbox :). I think I'd like to remove it altogether but don't know how to do that and I'm concerned about the implications of doing so (functionality, performance, etc.).

@kevinmarrec
Copy link
Owner

Setting pwa.workbox.enable: false, starting v0.16.0, will indeed unregister the service worker. Your website won't be broken but would no longer be installable due to lack of service worker which is one of the conditions to fullfil PWA installation checks.

In other terms, it would make your app not a PWA anymore, and only laverage the metas & icons features.

@kevinmarrec
Copy link
Owner

kevinmarrec commented Feb 20, 2023

Also, it seems https://github.com/nuxt/nuxt/releases/tag/v3.2.2 has an experimental thing related to nuxt/nuxt#14594 you mentioned.

You may find more info on related merged PR nuxt/nuxt#19038 notes, in complement of nuxt/nuxt#14594 which has been tagged as resolved.

I don't think I can't help more as I think some of the 404 you're facing are kind of expected behavior when the user already loaded the page, while a new deployment is made and then he interacts or navigates with old chunks.

@jastaffen
Copy link
Author

Hi @kevinmarrec, yeah when I started this issue, I said that I wasn't sure yet whether it was related to nuxt3 or the PWA. And it turns out that Nuxt3 did not have the same chunk error catch that was baked into nuxt2 whenever a new deployment was made and a server was trying to fetch a cached file that no longer existed, which is now part of it. I'm going to deploy my project with this update tomorrow when I'm at work, and we will see if the error persists. If it does, then I will feel suspicious again of the service worker.

Thank you for all your help / explanations on everything here. I will keep you posted. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants