metajack/strophejs — Issue #67: Strophe.Connection.disconnect infinite loop
Author: natefaubion
Created: 2011-10-27 19:17:45+00:00
State: open

I noticed when attempting a crossdomain connection that fails, the exception handler will call an infinite loop.

Starting in _processRequest, there's this block:

try {
req.xhr.open("POST", this.service, true);
} catch (e2) {
Strophe.error("XHR open failed.");
if (!this.connected) {
this._changeConnectStatus(Strophe.Status.CONNFAIL,
"bad-service");
}
this.disconnect();
return;
}

So when the POST fails, it calls disconnect(), which in turns calls _sendTerminate(), which will then create another POST request that will fail, resulting in an infinite loop.

In a working setup this shouldn't ever come up, but I figured this probably shouldn't be happening.