From 0bea595be3e8148c445ef9d9d77740f721513c5e Mon Sep 17 00:00:00 2001 From: Debadree Chatterjee Date: Sat, 18 Mar 2023 16:39:22 +0530 Subject: [PATCH] test: reduce flakiness of test-http-remove-header-stays-removed.js Refs: https://github.com/nodejs/reliability/issues/508 Refs: https://github.com/nodejs/node/pull/46333 PR-URL: https://github.com/nodejs/node/pull/46855 Reviewed-By: Matteo Collina --- test/parallel/test-http-remove-header-stays-removed.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 3885ebd905f758..6eba1799cd7d3f 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const http = require('http'); @@ -56,6 +56,14 @@ server.listen(0, function() { res.setEncoding('ascii'); res.on('data', function(chunk) { response += chunk; + if (response === 'beep boop\n') { + setTimeout(function() { + // The socket should be closed immediately, with no keep-alive, because + // no content-length or transfer-encoding are used: + assert.strictEqual(res.socket.closed, true); + server.close(); + }, common.platformTimeout(15)); + } }); }); });