From e14335c561eb259c0e6701bd4e60f178d48fcd3f Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 9 Sep 2023 14:44:31 +0200 Subject: [PATCH 1/2] test: deflake test-http-regr-gh-2928 Hard code the value of the host parameter to `common.localhostIPv4` in `server.listen()` and `net.connect()`. This 1. ensures that the client `socket._handle` is not reinitialized during connection due to the family autodetection algorithm, preventing `parser.consume()` from being called with an invalid `socket._handle` parameter. 2. works around an issue in the FreeBSD 12 machine where the stress test is run where some sockets get stuck after connection. PR-URL: https://github.com/nodejs/node/pull/49574 Closes: https://github.com/nodejs/node/pull/49565 Fixes: https://github.com/nodejs/node/issues/49564 Reviewed-By: Yagiz Nizipli Reviewed-By: James M Snell --- test/sequential/test-http-regr-gh-2928.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index 149aaeb6e6e420..25476e0453c53b 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -25,7 +25,7 @@ function execAndClose() { const parser = parsers.pop(); parser.initialize(HTTPParser.RESPONSE, {}); - const socket = net.connect(common.PORT); + const socket = net.connect(common.PORT, common.localhostIPv4); socket.on('error', (e) => { // If SmartOS and ECONNREFUSED, then retry. See // https://github.com/nodejs/node/issues/2663. @@ -57,7 +57,7 @@ const server = net.createServer(function(c) { c.end('HTTP/1.1 200 OK\r\n\r\n', function() { c.destroySoon(); }); -}).listen(common.PORT, execAndClose); +}).listen(common.PORT, common.localhostIPv4, execAndClose); process.on('exit', function() { assert.strictEqual(gotResponses, COUNT); From 4e81939cfbf5c60c49a42de42add900664ef1238 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 20 Oct 2023 14:56:44 +0200 Subject: [PATCH 2/2] test: reduce the number of requests and parsers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The maximum number of parsers in the free list is set to 1000. However the test does not need to use this maximum. Reduce it to 50. Refs: https://github.com/nodejs/node/pull/50228#issuecomment-1768293624 PR-URL: https://github.com/nodejs/node/pull/50240 Fixes: https://github.com/nodejs/node/issues/49564 Reviewed-By: Yagiz Nizipli Reviewed-By: Vinícius Lourenço Claro Cardoso --- test/sequential/test-http-regr-gh-2928.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index 25476e0453c53b..f6a9e1603288a4 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -8,6 +8,8 @@ const httpCommon = require('_http_common'); const { HTTPParser } = require('_http_common'); const net = require('net'); +httpCommon.parsers.max = 50; + const COUNT = httpCommon.parsers.max + 1; const parsers = new Array(COUNT);