Skip to content

Commit

Permalink
circumvent race condition due to changed http bits in 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
einaros committed Oct 23, 2011
1 parent f6c376d commit 79c3d84
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/transports.jsonp-polling.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ module.exports = {
});
},

'test the disconnection event when the client sends ?disconnect req':
function (done) {
'test the disconnection event when the client sends ?disconnect req': function (done) {
var cl = client(++ports)
, io = create(cl)
, disconnected = false
Expand All @@ -274,17 +273,22 @@ module.exports = {
res.statusCode.should.eql(200);
msgs.should.have.length(1);
msgs[0].type.should.eql('connect');

cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, msgs) {
msgs.should.have.length(1);
msgs[0].should.eql({ type: 'disconnect', endpoint: '' });
disconnected.should.be.true;
cl.end();
io.server.close();
cl.end();
done();
});

cl.get('/socket.io/{protocol}/jsonp-polling/' + sid + '/?disconnect');
// with the new http bits in node 0.5, there's no guarantee that
// the previous request is actually dispatched (and received) before the following
// reset call is sent. to not waste more time on a workaround, a timeout is added.
setTimeout(function() {
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid + '/?disconnect');
}, 500);
});
});
},
Expand Down

0 comments on commit 79c3d84

Please sign in to comment.