socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Websocket connection error cannot be caught by event handler

Open Domiii opened this issue 5 years ago • 1 comments

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:

image

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?

Domiii avatar Jan 23 '20 09:01 Domiii

This issue doesn't seem to have an activity this issue and looks everything is working as expected.

haneenmahd avatar Apr 30 '23 07:04 haneenmahd