msw
msw copied to clipboard
Cannot read properties of undefined (reading 'url')
Prerequisites
- [X] I confirm my issue is not in the opened issues
- [X] I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- [X] I'm using the latest
mswversion - [X] I'm using Node.js version 18 or higher
Browsers
Chromium (Chrome, Brave, etc.)
Reproduction repository
N/A
Reproduction steps
msw version: 2.3.0-ws.rc-7 - using it for the subscription mocking
I believe it's the same behavior and reason as described in this issue https://github.com/mswjs/msw/issues/2083.
Current behavior
Almost every time I reload my screen, or it is auto-reloaded it throws this error.
Cannot read properties of undefined (reading 'url')
Expected behavior
Does not throw this error.
This is a nasty bug. We use an error handler of last resort. When there is an unhandled exception it will tear down the application, try to send diagnostics and present a generic error message to the user.
All we can do here is check if the error message is equal to Cannot read properties of undefined (reading 'url') and pray this rather generic error was really emitted by msw.
In my case, it happens only in the development mode. When it happens I simply close the React error popup and continue working. It is not super intrusive, but it would be great if it didn't occur.
Looks like a duplicate of #2146. Let's track it there.