LearnBoost/socket.io-client — pull request #658 by dotnetwise (2014-04-22 13:26:30+00:00)
Title: 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!