Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure we only handle the onclose event once

Fixes an issue when trying to establish the connection with
Firefox 13 fails during the handshake. It would call onclose twice.
  • Loading branch information...
commit 8ab7895ce50ec1a66442562d86945fd6000545fd 1 parent a13fd36
@essen essen authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 priv/bullet.js
View
10 priv/bullet.js
@@ -169,6 +169,7 @@
}
var stream = new function(){
+ var isClosed = true;
var readyState = CLOSED;
var heartbeat;
var delay = delayDefault = 80;
@@ -176,6 +177,7 @@
var transport;
function init(){
+ isClosed = false;
readyState = CONNECTING;
transport = next();
@@ -202,6 +204,12 @@
}
};
transport.onclose = function(){
+ // Firefox 13.0.1 sends 2 close events.
+ // Return directly if we already handled it.
+ if (isClosed){
+ return;
+ }
+
clearInterval(heartbeat);
if (readyState == CLOSING){
@@ -218,6 +226,8 @@
delay = delayMax;
}
+ isClosed = true;
+
setTimeout(function(){
init();
}, delay);
Please sign in to comment.
Something went wrong with that request. Please try again.