MSW fails to start Mock because worker update() fails. #2006
Labels
bug
Something isn't working
needs:triage
Issues that have not been investigated yet.
scope:browser
Related to MSW running in a browser
Prerequisites
Environment check
msw
versionBrowsers
Chromium (Chrome, Brave, etc.), Firefox
Reproduction repository
https://codesandbox.io/p/devbox/msw-react-xx1c8
Reproduction steps
Can't make a reproduction repository, it depends if my backend is accessible. If backend is running, MSW mock starts and do his job. MSW fails to start mock with SetupWorker.start() when server is not reachable.
To reproduce, I have to stop my backend that serves assets and bundle.js resources.
Current behavior
The function that find existing registration of the service worker is trying to update it and returns fetch error below because service-worker.js resources is not accessible.
getWorkerInstance.ts :
if (existingRegistration) { // When the Service Worker is registered, update it and return the reference. return existingRegistration.update().then(() => { return [ getWorkerByRegistration( existingRegistration, absoluteWorkerUrl, findWorker, ), existingRegistration, ] }) }
I'm asking, why do we need to call update() on existingRegistration before returning worker instance if worker is active ?
Expected behavior
Suggestion:
The text was updated successfully, but these errors were encountered: