socket: fix closing the socket in an open listener [mmastrac]

This commit is contained in:
Guillermo Rauch
2012-12-03 08:53:46 -03:00
parent 31460d8407
commit 0cb254539e

View File

@@ -255,7 +255,9 @@ Socket.prototype.onOpen = function () {
this.onopen && this.onopen.call(this);
this.flush();
if (this.upgrade && this.transport.pause) {
// we check for `readyState` in case an `open`
// listener alreay closed the socket
if ('open' == this.readyState && this.upgrade && this.transport.pause) {
debug('starting upgrade probes');
for (var i = 0, l = this.upgrades.length; i < l; i++) {
this.probe(this.upgrades[i]);