diff --git a/package.json b/package.json index 0015dccd16..3bb32cc30c 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "test": "mocha --reporter dot --slow 200ms --bail" }, "dependencies": { - "engine.io": "1.6.7", + "engine.io": "nkzawa/engine.io#graceful-close", "socket.io-parser": "2.2.6", "socket.io-client": "1.4.4", "socket.io-adapter": "0.4.0", diff --git a/test/fixtures/server-close.js b/test/fixtures/server-close.js new file mode 100644 index 0000000000..68917462b2 --- /dev/null +++ b/test/fixtures/server-close.js @@ -0,0 +1,11 @@ +var server = require('http').createServer(); +var ioc = require('socket.io-client'); +var io = require('../..')(server); + +var srv = server.listen(function() { + var socket = ioc('ws://localhost:' + server.address().port); + socket.on('connect', function() { + io.close(); + socket.close(); + }); +}); diff --git a/test/socket.io.js b/test/socket.io.js index a576ed498f..eb1a8308b9 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -3,6 +3,7 @@ var http = require('http').Server; var io = require('..'); var fs = require('fs'); var join = require('path').join; +var exec = require('child_process').exec; var ioc = require('socket.io-client'); var request = require('supertest'); var expect = require('expect.js'); @@ -412,6 +413,16 @@ describe('socket.io', function(){ }); }); + describe('graceful close', function(){ + function fixture(filename) { + return process.execPath + ' ' + + join(__dirname, 'fixtures', filename); + } + + it('should stop socket and timers', function(done){ + exec(fixture('server-close.js'), done); + }); + }); }); describe('namespaces', function(){