diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 7e90bd2f79ba47..28c27891af7951 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -20,12 +20,6 @@ const server = net.createServer(function(socket) { const client = new net.Socket(); -server.on('close', common.mustCall(function() { - assert.deepEqual(clientLocalPorts, serverRemotePorts, - 'client and server should agree on the ports used'); - assert.equal(2, conns); -})); - server.listen(common.PORT, common.localhostIPv4, testConnect); function testConnect() { @@ -44,3 +38,9 @@ function testConnect() { }); conns++; } + +process.on('exit', function() { + assert.deepEqual(clientLocalPorts, serverRemotePorts, + 'client and server should agree on the ports used'); + assert.equal(2, conns); +});