Skip to content

Commit

Permalink
test: fix flaky test-https-set-timeout-server
Browse files Browse the repository at this point in the history
Because of a race condition, connection listener may not be invoked if
test is run under load. Remove `common.mustCall()` wrapper from the
listener. Move the test to `parallel` because it now works under load.
Make similar change to http test to keep them in synch even though it is
much harder to trigger the race in http.

Fixes: nodejs#14133
  • Loading branch information
Trott committed Jul 8, 2017
1 parent 6a1b813 commit 25d6100
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions test/parallel/test-http-set-timeout-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ function run() {
}

test(function serverTimeout(cb) {
const server = http.createServer(common.mustCall((req, res) => {
// just do nothing, we should get a timeout event.
}));
const server = http.createServer((req, res) => {
// Do nothing. We should get a timeout event.
// Might not be invoked. Do not wrap in common.mustCall().
});
server.listen(common.mustCall(() => {
const s = server.setTimeout(50, common.mustCall((socket) => {
socket.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ function run() {
test(function serverTimeout(cb) {
const server = https.createServer(
serverOptions,
common.mustCall((req, res) => {
// just do nothing, we should get a timeout event.
}));
(req, res) => {
// Do nothing. We should get a timeout event.
// Might not be invoked. Do not wrap in common.mustCall().
});
server.listen(common.mustCall(() => {
const s = server.setTimeout(50, common.mustCall((socket) => {
socket.destroy();
Expand Down

0 comments on commit 25d6100

Please sign in to comment.