Skip to content

Commit

Permalink
test: deflake test-http-regr-gh-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: #49574
Closes: #49565
Fixes: #49564
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lpinca committed Sep 18, 2023
1 parent b651e37 commit 18e00a5
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 18e00a5

Please sign in to comment.