From 776485485859bf8ba6a65c7734c076c9c03453fe 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. Fixes: https://github.com/nodejs/node/issues/13020 --- 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 cdb97ef8f27bc8..a693f94efbb9d1 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;