From 2da1af0a9320d613ca0107ed39087e23b9719369 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Mon, 17 Jul 2017 10:21:21 -0700 Subject: [PATCH] test: fix test-async-wrap-getasyncid flakyness The test used to assume that if the client successfully writes data to the server and closes the connection, then the server must have received that data and ran its connection callback wrapped by common.mustCall. However, it is not necessarily the case, and as a result the test was flaky. With this change, the server is closed only once the server's connection callback has been called, which guarantees that the server can accept connections until it actually accepted the single connection that this test requires to accept, making the test not flaky. PR-URL: https://github.com/nodejs/node/pull/14329 Fixes: https://github.com/nodejs/node/issues/13020 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Anna Henningsen Reviewed-By: Wyatt Preul --- test/parallel/test-async-wrap-getasyncid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-async-wrap-getasyncid.js b/test/parallel/test-async-wrap-getasyncid.js index cdb97ef8f27..a693f94efbb 100644 --- a/test/parallel/test-async-wrap-getasyncid.js +++ b/test/parallel/test-async-wrap-getasyncid.js @@ -160,6 +160,7 @@ if (common.hasCrypto) { const stream_wrap = process.binding('stream_wrap'); const tcp_wrap = process.binding('tcp_wrap'); const server = net.createServer(common.mustCall((socket) => { + server.close(); socket.on('data', (x) => { socket.end(); socket.destroy(); @@ -176,7 +177,6 @@ if (common.hasCrypto) { sreq.oncomplete = common.mustCall(() => { handle.close(); - server.close(); }); wreq.handle = handle;