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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Wyatt Preul <[email protected]>
  • Loading branch information
Julien Gilli committed Jul 25, 2017
1 parent c24a73d commit 2da1af0
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 2da1af0

Please sign in to comment.