Skip to content

Commit ae7eeff

Browse files
TrottMylesBorins
authored andcommitted
test: fix flaky test-https-set-timeout-server
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. PR-URL: #14134 Fixes: #14133 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent 01d82d8 commit ae7eeff

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

test/parallel/test-http-set-timeout-server.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ function run() {
2121
}
2222

2323
test(function serverTimeout(cb) {
24-
const server = http.createServer(common.mustCall((req, res) => {
25-
// just do nothing, we should get a timeout event.
26-
}));
24+
const server = http.createServer((req, res) => {
25+
// Do nothing. We should get a timeout event.
26+
// Might not be invoked. Do not wrap in common.mustCall().
27+
});
2728
server.listen(common.mustCall(() => {
2829
const s = server.setTimeout(50, common.mustCall((socket) => {
2930
socket.destroy();

test/sequential/test-https-set-timeout-server.js test/parallel/test-https-set-timeout-server.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ function run() {
3636
test(function serverTimeout(cb) {
3737
const server = https.createServer(
3838
serverOptions,
39-
common.mustCall((req, res) => {
40-
// just do nothing, we should get a timeout event.
41-
}));
39+
(req, res) => {
40+
// Do nothing. We should get a timeout event.
41+
// Might not be invoked. Do not wrap in common.mustCall().
42+
});
4243
server.listen(common.mustCall(() => {
4344
const s = server.setTimeout(50, common.mustCall((socket) => {
4445
socket.destroy();

0 commit comments

Comments
 (0)