-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Firefox causes ws server to raise "TypeError: Cannot set property 'readyState' of undefined" (with MCVE) #1738
Comments
See #1704. |
To fix the problem change this line https://github.com/canadaduane/ws-mcve-undefined-readystate/blob/master/minimal.js#L9 to const wss = new WebSocket.Server({ noServer: true }); |
I put quite a bit of effort into showing how this error arises. I'd be gratified if future users of ws didn't accidentally run into the same (less than helpful) error message. |
This commit 3641266 attempted to detect the invalid usage and provide a better message but your (and other) particular configurations are not covered. I can think of way to catch all cases but the error message would be something like "The socket is already being used by another WebSocket" which is even more confusing for the end user, I guess. |
By the way the bug report was top notch. Thanks. |
I think "The socket is already being used by another WebSocket" is actually a pretty good error in this case. I suspected my configuration was incorrect, but couldn't understand how the error message related to my config. |
Also, getting two different errors, dependent upon browser used, added to my confusion. |
I've opened #1742. Suggestions and feedback are welcomed. |
Note: "Minimal, Complete, Reproducible Example" at http://github.com/canadaduane/ws-mcve-undefined-readystate
Description
When running express http and ws on the same port (and perhaps in a misconfigured way) Firefox will cause ws to fail with the following error:
Note that initiating a websocket connection from Chrome causes a different error:
Reproducible in:
Steps to reproduce:
git clone git@github.com:canadaduane/ws-mcve-undefined-readystate.git
yarn install
yarn start
and visit http://localhost:3000 in FirefoxExpected result:
Should raise a better error if I've misconfigured something, or no error at all if everything is OK.
Actual result:
After waiting up to 30 seconds, the above "TypeError: Cannot set property 'readyState' of undefined" crashes the server.
The text was updated successfully, but these errors were encountered: