Skip to content

Commit

Permalink
Merge pull request #923 from iamdoron/master
Browse files Browse the repository at this point in the history
remove connection event listeners when server stops
  • Loading branch information
Eran Hammer committed Jun 11, 2013
2 parents 9a5425b + c9257dd commit 01bec39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ internals.Server.prototype._stop = function (options, callback) {
}, options.timeout);

self.listener.close(function () {

self.listener.removeAllListeners()
clearTimeout(timeoutId);
callback();
});
Expand Down
14 changes: 14 additions & 0 deletions test/integration/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,18 @@ describe('Server', function () {
});
});
});
it('removes connection event listeners after it stops', function (done) {

var server = Hapi.createServer(0);
server.start(function () {
server.stop(function () {
server.start(function () {
server.stop(function () {
expect(server.listeners('connection').length).to.be.eql(0);
done();
});
});
});
});
});
});

0 comments on commit 01bec39

Please sign in to comment.