-
Notifications
You must be signed in to change notification settings - Fork 3
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
MSW intercepts plain WebSocket but fails to intercept Socket.IO connections #12
Comments
Hi, @ccpu. Thanks for reporting this. I think you should drop Please give that a try and let me know if that helps. Following the Debugging runbook might also help. For example, provide the |
Hi, @kettanaito, Thanks for the suggestions. Dropping Even more puzzling, onUnhandledRequest isn't printing any messages (via console.log). It seems that MSW is unable to mock the Socket.IO connection because Socket.IO uses a specific handshake protocol that's challenging to intercept with MSW's WebSocket mocking system. |
I know, that's why you shouldn't append/change it yourself. MSW understands the specific SocketIO handshake protocol in the |
I'm encountering a problem in my local development environment when using MSW with Socket.IO. For some strange reason, MSW is able to intercept a plain WebSocket connection when I use:
However, it fails to intercept when I use the Socket.IO client:
Note that Socket.IO client automatically appends
/socket.io/
to the URL, so both are attempting to connect to the same endpoint.I have created a minimal reproduction:
The GitHub repo might be more reliable for reproduction.
Any idea what I might be doing wrong or what modifications are needed to allow MSW to intercept Socket.IO connections as it does with a plain WebSocket?
Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: