-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Using generateSW for my service worker, when I boot up a new build and do a page refresh or navigate to a route that throws a SvelteKit error (either from a load function in +page.ts or just a missing route), the client seems to get stuck in an infinite loop of navigating to the same page that generated the error and requesting /_app/version.json from the server.
Workbox repeatedly reports a full page navigation in the log (always to the same page) and triggering the associated invalidation of page data, and eventually things get halted by Chrome navigation throttling.
The issue only occurs on routes that throw errors from a +page.ts load function or are missing entirely (triggering the SvelteKit fallback error page). If I "start" on any non-error-generating page and only navigate to the error-generating one after the update, error handling works as normal again. Same goes for offline mode (since no new SW versions are found).
Service workers are still pretty new to me, so I haven't been able to identify what could be the trigger of this conflict between the fetch of new updates and SvelteKit errors. I would have assumed the behavior of purely client-side +error.svelte / +page.load interactions would behave similarly to just in-lining an {#if error} ... page in page.svelte, yet one plays nice with the service worker and the other does not.
I've been able to replicate it both in local builds and deployed builds on Vercel, so can exclude that it's related to http vs. https or any other local dev environment factors. Happy to provide more info / reproduce in a fresh repo if needed, otherwise will post here if I find a fix.