Skip to content

Commit

Permalink
test: fix parallel/test-http-destroyed-socket-write2
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bnoordhuis committed Jan 23, 2015
1 parent 5ba307a commit 4f95b5d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/parallel/test-http-destroyed-socket-write2.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ server.listen(common.PORT, function() {
method: 'POST'
});

var timer = setImmediate(write);
var timer = setTimeout(write, 50);
var writes = 0;

function write() {
Expand All @@ -28,7 +28,7 @@ server.listen(common.PORT, function() {
req.end();
test();
} else {
timer = setImmediate(write);
timer = setTimeout(write, 50);
req.write('hello');
}
}
Expand All @@ -45,6 +45,9 @@ server.listen(common.PORT, function() {
case 'ECONNRESET':
// On windows this sometimes manifests as ECONNABORTED
case 'ECONNABORTED':
// This test is timing sensitive so an EPIPE is not out of the question.
// It should be infrequent, given the 50 ms timeout, but not impossible.
case 'EPIPE':
break;
default:
assert.strictEqual(er.code,
Expand Down

0 comments on commit 4f95b5d

Please sign in to comment.