Skip to content

Commit

Permalink
test: deflake test-http-regr-nodejsgh-2928
Browse files Browse the repository at this point in the history
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: nodejs#49574
Closes: nodejs#49565
Fixes: nodejs#49564
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lpinca authored and alexfernandez committed Nov 1, 2023
1 parent 0a8bb2a commit 01bfc37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/sequential/test-http-regr-gh-2928.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 01bfc37

Please sign in to comment.