From c1c2b5c9e17b441414427d2d76886604b1078af7 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 30 Mar 2019 15:09:19 +0100 Subject: [PATCH 1/2] test: move test-net-connect-handle-econnrefused The port used in the test could be taken by another process before the callback of `server.close()` is called. Move it to sequential. Refs: https://github.com/nodejs/node/pull/18257#discussion_r162717096 Fixes: https://github.com/nodejs/node/issues/26907 --- .../test-net-connect-handle-econnrefused.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{parallel => sequential}/test-net-connect-handle-econnrefused.js (100%) diff --git a/test/parallel/test-net-connect-handle-econnrefused.js b/test/sequential/test-net-connect-handle-econnrefused.js similarity index 100% rename from test/parallel/test-net-connect-handle-econnrefused.js rename to test/sequential/test-net-connect-handle-econnrefused.js From 325fd72f23ff7c247f1b261efba12d64e65d026c Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 30 Mar 2019 15:27:45 +0100 Subject: [PATCH 2/2] test: refactor net-connect-handle-econnrefused - Remove unneeded server - Use `common.PORT` --- .../test-net-connect-handle-econnrefused.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/test/sequential/test-net-connect-handle-econnrefused.js b/test/sequential/test-net-connect-handle-econnrefused.js index c1ccfc23384caf..3cb7d014b436a4 100644 --- a/test/sequential/test-net-connect-handle-econnrefused.js +++ b/test/sequential/test-net-connect-handle-econnrefused.js @@ -24,13 +24,8 @@ const common = require('../common'); const net = require('net'); const assert = require('assert'); -const server = net.createServer(); -server.listen(0); -const port = server.address().port; -server.close(common.mustCall(() => { - const c = net.createConnection(port); - c.on('connect', common.mustNotCall()); - c.on('error', common.mustCall((e) => { - assert.strictEqual(e.code, 'ECONNREFUSED'); - })); +const c = net.createConnection(common.PORT); +c.on('connect', common.mustNotCall()); +c.on('error', common.mustCall((e) => { + assert.strictEqual(e.code, 'ECONNREFUSED'); }));