socket.io
socket.io copied to clipboard
Websocket connection error cannot be caught by event handler
You want to:
- [x] report a bug
- [ ] request a feature
Problem Description
Connection fails silently, causing headaches and hours of time spent debugging.
I had a problem in my webpack build, causing connection to fail silently on Node, caused by this websocket issue (which in turn is caused by webpack's broken default build settings).
To be clear: This bug is not caused by engine.io, but it is accidentally silencing it.
Specifically, the problem is in websocket.doOpen's try/catch handler. It will emit the error, but since, the first time around, doOpen is called from the Manager.constructor, it would be impossible to register any event handler at that point, making this error always go unnoticed, no matter what you do.
Here is the callstack:

Steps to reproduce (if the current behaviour is a bug)
Anything that causes websocket.doOpen to fail (such as a default webpack build run on Node) will fail silently.
Discussion
Maybe there should be a default error handler that acts if none was registered? This would alsomake it easier for people to get started and reliably find any potential problem without having to debug the dependency?
As an alternative, I am also thinking, straight up throwing the error when it happens in the constructor (or in general, if no error handler is provided) would still be better than what it is right now?
This issue doesn't seem to have an activity this issue and looks everything is working as expected.