From bd774d9039828db4792f8fb452f69b104360ad6a Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 11 Nov 2019 16:51:28 +0100 Subject: [PATCH] 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. --- test/parallel/parallel.status | 2 -- test/parallel/test-http-dump-req-when-res-ends.js | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 3cb5065c82b51f..444cf8d1154c92 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -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] diff --git a/test/parallel/test-http-dump-req-when-res-ends.js b/test/parallel/test-http-dump-req-when-res-ends.js index 718797fae1fe68..01dbbca1b393fb 100644 --- a/test/parallel/test-http-dump-req-when-res-ends.js +++ b/test/parallel/test-http-dump-req-when-res-ends.js @@ -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(); }); }));