From 37b2da53c3fb73c9fa373b8d500b6b8f30fa55d1 Mon Sep 17 00:00:00 2001 From: Debadree Chatterjee Date: Mon, 27 Feb 2023 12:51:29 +0530 Subject: [PATCH] test: reduce flakiness of test/parallel/test-http-remove-header-stays-removed.js Refs: https://github.com/nodejs/reliability/issues/508 Refs: https://github.com/nodejs/node/pull/46333 --- .../test-http-remove-header-stays-removed.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 92c1e45dd25d01..8073c94fcbc270 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'); @@ -54,13 +54,14 @@ server.listen(0, function() { res.setEncoding('ascii'); res.on('data', function(chunk) { response += chunk; + if (response?.toString() === '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)); + } }); - - 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(); - }, 10); }); });