summaryrefslogtreecommitdiff
path: root/test/simple/test-net-server-close.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-03-06 16:15:17 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2013-03-06 16:15:18 +0100
commitfb3ec32b0ea5e42f6a9a8f0d5f43779f92cfac4a (patch)
tree129d0e8cba32085dc9715c1449ce1dd97e3f7d28 /test/simple/test-net-server-close.js
parent958ab661cbede92470ffd47b23607c61f5e61e17 (diff)
downloadnode-new-fb3ec32b0ea5e42f6a9a8f0d5f43779f92cfac4a.tar.gz
net: use close callback, not process.nextTick
Don't emit the 'close' event with process.nextTick. Closing a handle is an operation that usually *but not always* completes on the next tick of the event loop, hence using process.nextTick is not reliable. Use a proper handle close callback and emit the 'close' event from inside the callback. Update tests that depend on the intricacies of the old model. Fixes #3459.
Diffstat (limited to 'test/simple/test-net-server-close.js')
-rw-r--r--test/simple/test-net-server-close.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/simple/test-net-server-close.js b/test/simple/test-net-server-close.js
index b87a84d96f..afa83f10d6 100644
--- a/test/simple/test-net-server-close.js
+++ b/test/simple/test-net-server-close.js
@@ -28,7 +28,11 @@ var sockets = [];
process.on('exit', function() {
assert.equal(server.connections, 0);
- assert.deepEqual(events, 'client client server'.split(' '));
+ assert.equal(events.length, 3);
+ // Expect to see one server event and two client events. The order of the
+ // events is undefined because they arrive on the same event loop tick.
+ assert.equal(events.join(' ').match(/server/g).length, 1);
+ assert.equal(events.join(' ').match(/client/g).length, 2);
});
var server = net.createServer(function(c) {