Skip to content
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

The currently registered Service Worker has been generated by a different version of MSW (undefined) #2119

Open
4 tasks done
kettanaito opened this issue Apr 1, 2024 · 1 comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser

Comments

@kettanaito
Copy link
Member

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

Browsers

No response

Reproduction repository

Reproduction steps

  1. Set up MSW in a browser.
  2. Perform an unhandled request.

Current behavior

entry.client.tsx:20 [MSW] The currently registered Service Worker has been generated by a different version of MSW (undefined) and may not be fully compatible with the installed version.

It's recommended you update your worker script by running this command:

  • npx msw init <PUBLIC_DIR>

You can also automate this process and make the worker script update automatically upon the library installations. Read more: https://mswjs.io/docs/cli/init.

Expected behavior

Should print the actual MSW version, not (undefined).

@kettanaito kettanaito added bug Something isn't working scope:browser Related to MSW running in a browser needs:triage Issues that have not been investigated yet. labels Apr 1, 2024
@robdodson
Copy link

@kettanaito I have seen this issue and was wondering if it's just because an unhandled request is happening, or if the msw version is also out of date?

We have a monorepo of SPAs with a root package.json, and then each directory holds an SPA with its own public dir. For example:

.
├── appA
│   ├── public
│       └── mockServiceWorker.js
├── appB
│   ├── public
│       └── mockServiceWorker.js
├── package.json

The SPAs are all sharing the same mockServiceWorker.js file with a PACKAGE_VERSION of 2.2.13, which matches the version in our root package.json. But I was wondering how the mockServiceWorker file checks its version and if it needs to be told where to find the package.json?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser
Projects
None yet
Development

No branches or pull requests

2 participants