Blank request can get sent after disconnection (depending on timing)
hulusjang opened this issue · comments
Steve Jang commented
In the following code (core.js, inside _onIdle, line 3589):
if (this._requests.length < 2 && this._data.length > 0 &&
!this.paused) {
...
this._requests.push( // <--------------- line 3589
new Strophe.Request(body.tree(),
this._onRequestStateChange.bind(
this, this._dataRecv.bind(this)),
body.tree().getAttribute("rid")));
this._processRequest(this._requests.length - 1);
}
Depending on timing, this code seems to queue a poll request even after "terminate" message has been processed. This results in 404 being returned from server, and causes uncaught exception: TypeError: elem.getAttribute is not a function.
Perhaps, we should check for this.disconnecting variable before queuing a new request?
Here is a quick fix for this problem. However, a better fix should be possible:
if (!this.disconnecting) {
this._requests.push(
new Strophe.Request(body.tree(),
this._onRequestStateChange.bind(
this, this._dataRecv.bind(this)),
body.tree().getAttribute("rid")));
}
if (this._requests.length > 0) {
this._processRequest(this._requests.length - 1);
}