Skip to content

Commit 4f95b5d

Browse files
committed
test: fix parallel/test-http-destroyed-socket-write2
Ameliorate a timing sensitivity issue by switching from setImmediate() to setTimeout() with a 50 ms timeout. This commit also adds EPIPE as an accepted error (besides ECONNABORT and ECONNRESET) because that's a plausible outcome given the timing sensitive nature of test. PR-URL: #575 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
1 parent 5ba307a commit 4f95b5d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/parallel/test-http-destroyed-socket-write2.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server.listen(common.PORT, function() {
1919
method: 'POST'
2020
});
2121

22-
var timer = setImmediate(write);
22+
var timer = setTimeout(write, 50);
2323
var writes = 0;
2424

2525
function write() {
@@ -28,7 +28,7 @@ server.listen(common.PORT, function() {
2828
req.end();
2929
test();
3030
} else {
31-
timer = setImmediate(write);
31+
timer = setTimeout(write, 50);
3232
req.write('hello');
3333
}
3434
}
@@ -45,6 +45,9 @@ server.listen(common.PORT, function() {
4545
case 'ECONNRESET':
4646
// On windows this sometimes manifests as ECONNABORTED
4747
case 'ECONNABORTED':
48+
// This test is timing sensitive so an EPIPE is not out of the question.
49+
// It should be infrequent, given the 50 ms timeout, but not impossible.
50+
case 'EPIPE':
4851
break;
4952
default:
5053
assert.strictEqual(er.code,

0 commit comments

Comments
 (0)