App dies if socket disconnects right in onConnect #658

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant

App dies if socket disconnects between in onConnect handler emitting the 'connect' message

This is the code throwing the exception from the emit method

WebSocket.prototype.send = function(data, options, cb) {
...
if (this.readyState != WebSocket.OPEN) {
    if (typeof cb == 'function') cb(new Error('not opened'));
    else throw new Error('not opened');
    return;
  }
...

For some strange reason some times, the client socket will receive the onConnect method but will disconnect just before emitting the connect message, so with the above exception, the app will die!

@adaptabi adaptabi App dies if socket disconnects right in onConnect
App dies if socket disconnects between in `onConnect` handler emitting the 'connect' message

This is the code throwing the exception from the `emit` method
```js
WebSocket.prototype.send = function(data, options, cb) {
...
if (this.readyState != WebSocket.OPEN) {
    if (typeof cb == 'function') cb(new Error('not opened'));
    else throw new Error('not opened');
    return;
  }
...
```

For some strange reason some times, the client socket will receive the onConnect method but will disconnect just before emitting the `connect` message, so with the above exception, the app will die!
96c38f8

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment