Skip to content

Commit

Permalink
test: fix test-async-wrap-getasyncid flakyness
Browse files Browse the repository at this point in the history
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: #14329
Fixes: #13020
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
  • Loading branch information
Julien Gilli authored and addaleax committed Jul 27, 2017
1 parent 3c50c59 commit aeb8d66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/parallel/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -176,7 +177,6 @@ if (common.hasCrypto) {

sreq.oncomplete = common.mustCall(() => {
handle.close();
server.close();
});

wreq.handle = handle;
Expand Down

0 comments on commit aeb8d66

Please sign in to comment.