Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Only call xhr.abort() on error cases in polling-xhr.js #319

Merged
merged 1 commit into from

2 participants

@samcday

How about this as a fix for #318?

@rauchg
Owner

@samcday interesting. Can we get a test for this?

@rauchg
Owner

Thanks!

@samcday

@guille If you deem this not mergeable because of the lack of a test, then please go ahead and close the PR. Realistically I'm not gonna have time to sit down and re-acquaint myself with the changes I made here and the test runner for engine.io-client in the near term.

@rauchg
Owner

We'll take care of it then!

@rauchg rauchg merged commit 61648de into from
@samcday

Awesome, thanks mate :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/transports/polling-xhr.js
View
12 lib/transports/polling-xhr.js
@@ -248,7 +248,7 @@ Request.prototype.onData = function(data){
Request.prototype.onError = function(err){
this.emit('error', err);
- this.cleanup();
+ this.cleanup(true);
};
/**
@@ -257,16 +257,18 @@ Request.prototype.onError = function(err){
* @api private
*/
-Request.prototype.cleanup = function(){
+Request.prototype.cleanup = function(fromError){
if ('undefined' == typeof this.xhr || null === this.xhr) {
return;
}
// xmlhttprequest
this.xhr.onreadystatechange = empty;
- try {
- this.xhr.abort();
- } catch(e) {}
+ if (fromError) {
+ try {
+ this.xhr.abort();
+ } catch(e) {}
+ }
if (global.document) {
delete Request.requests[this.index];
Something went wrong with that request. Please try again.