-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Chrome reloads infinitely when serviceWorker.options.scope
is set
#1627
Comments
If you interrupt the reload at the right time, you can take a peek at the code that requested the reload from the initiator tab. reproduction-2.movAccording to this, the following code appears to be causing infinite reloads:
|
In addition to Chrome, this problem was reproduced in Firefox. However, it did not reproduce in Safari. |
same problem for me |
This problem does not yet seem to have been fixed. FYI: You can temporarily work around this issue by installing ServiceWorker in the root path instead of using scope. This workaround only works for applications where it is not required to install under a subpath. |
Can confirm the same is happening for me.
|
This is my workaround which maybe useful for some cases. For me, I got infinite reload when init mswjs outside of service worker scope. let's say
workaround
if (window.location.pathname.startsWith('/some-path/')) { // only init mswjs when path is in service worker scope
const worker = setupWorker(...handlers);
void worker.start({
serviceWorker: {
url: '/some-path/mockServiceWorker.js',
}
});
} |
This problem still exits in Here is the workaround:
apps/app1/src/App.tsx:
apps/app1/vite.config.ts:
|
Thanks for the workaround! Alternatively, if you own your Web hosting server it is possible to "upgrade" SW scope by using Service-Worker-Allowed .ie including |
Prerequisites
Environment check
msw
versionBrowsers
Chromium (Chrome, Brave, etc.)
Reproduction repository
https://github.com/mizdra/reproduction-msw-scope-bug
Reproduction steps
npm i
npm run dev
Google Chrome 112.0.5615.137(Official Build) (arm64)
on masOS Monterey 12.6.Current behavior
Reloading the page many times at short intervals will cause it to enter an infinite reload loop.
reproduction-1.mov
Expected behavior
No infinite loops.
The text was updated successfully, but these errors were encountered: