From 816bf1d19c22dffb2deaa8e0870d54926bbb908c Mon Sep 17 00:00:00 2001 From: vedratna-velani Date: Wed, 21 Dec 2011 11:21:13 +0530 Subject: [PATCH] fix for broken closeTimeout and 'IE + xhr' goes into infinite loop on disconnection --- lib/transport.js | 2 +- lib/transports/xhr-polling.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/transport.js b/lib/transport.js index 5fe15471..a579faf1 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -45,7 +45,7 @@ // If the connection in currently open (or in a reopening state) reset the close // timeout since we have just received data. This check is necessary so // that we don't reset the timeout on an explicitly disconnected connection. - if (this.connected || this.connecting || this.reconnecting) { + if (this.socket.connected || this.socket.connecting || this.socket.reconnecting) { this.setCloseTimeout(); } diff --git a/lib/transports/xhr-polling.js b/lib/transports/xhr-polling.js index 1677ce82..82589272 100644 --- a/lib/transports/xhr-polling.js +++ b/lib/transports/xhr-polling.js @@ -88,14 +88,20 @@ function onload () { this.onload = empty; + this.onerror = empty; self.onData(this.responseText); self.get(); }; + function onerror () { + self.onClose(); + }; + this.xhr = this.request(); if (global.XDomainRequest && this.xhr instanceof XDomainRequest) { - this.xhr.onload = this.xhr.onerror = onload; + this.xhr.onload = onload; + this.xhr.onerror = onerror; } else { this.xhr.onreadystatechange = stateChange; } @@ -113,7 +119,7 @@ io.Transport.XHR.prototype.onClose.call(this); if (this.xhr) { - this.xhr.onreadystatechange = this.xhr.onload = empty; + this.xhr.onreadystatechange = this.xhr.onload = this.xhr.onerror = empty; try { this.xhr.abort(); } catch(e){}