Skip to content

Commit

Permalink
fix the case where done() called multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzawa committed Nov 26, 2015
1 parent 281bf7e commit e55cf32
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ describe('Transport', function () {
var socket = new eio.Socket();
expect(socket.transport.name).to.be('polling');

var timedout = false;
var timeout = setTimeout(function(){
timedout = true;
socket.close();
done();
}, 300);

socket.on('upgrade', function (transport) {
if (timedout) return;
clearTimeout(timeout);
socket.close();
if(transport.name == 'websocket') {
Expand All @@ -30,12 +33,15 @@ describe('Transport', function () {
var socket = new eio.Socket();
expect(socket.transport.name).to.be('polling');

var timedout = false;
var timeout = setTimeout(function(){
timedout = true;
socket.close();
done();
}, 300);

socket.on('upgrade', function (transport) {
if (timedout) return;
clearTimeout(timeout);
socket.close();
if(transport.name == 'websocket') {
Expand Down

0 comments on commit e55cf32

Please sign in to comment.