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.

Fixes: nodejs#13020
  • Loading branch information
Julien Gilli committed Jul 17, 2017
1 parent a6cec04 commit 7764854
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 7764854

Please sign in to comment.