Skip to content

Commit

Permalink
test: deflake test-http-dump-req-when-res-ends.js
Browse files Browse the repository at this point in the history
On some platforms the `'end'` event might not be emitted because the
socket could be destroyed by the other peer while the client is still
sending the data triggering an error. Use the `'close'` event instead.

PR-URL: #30360
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
lpinca authored and targos committed Dec 1, 2019
1 parent 1ef1f4f commit b685d7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Expand Up @@ -19,8 +19,6 @@ test-worker-memory: PASS,FLAKY
test-http2-client-upload: PASS,FLAKY
# https://github.com/nodejs/node/issues/20750
test-http2-client-upload-reject: PASS,FLAKY
# https://github.com/nodejs/node/issues/30011
test-http-dump-req-when-res-ends: PASS,FLAKY

[$system==linux]

Expand Down
8 changes: 6 additions & 2 deletions test/parallel/test-http-dump-req-when-res-ends.js
Expand Up @@ -48,8 +48,12 @@ server.listen(0, mustCall(function() {

res.resume();

// Wait for the response.
res.on('end', function() {
// On some platforms the `'end'` event might not be emitted because the
// socket could be destroyed by the other peer while data is still being
// sent. In this case the 'aborted'` event is emitted instead of `'end'`.
// `'close'` is used here because it is always emitted and does not
// invalidate the test.
res.on('close', function() {
server.close();
});
}));
Expand Down

0 comments on commit b685d7d

Please sign in to comment.