test: deflake test-http-dump-req-when-res-ends.js

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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Luigi Pinca authored and Myles Borins committed 2019-11-17 00:39:59 -08:00
1 parent e4a296ce8d
commit 109da52141
2 files changed
+6 -4

No files matched your search

-2
View File
@@ -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]
@@ -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();
});
}));