Skip to content

Commit 333ece2

Browse files
committed
test(daemon-server): blocker must use Node's default listen host to match the daemon
Previous attempt bound the blocker to 0.0.0.0, but Node's default when no host is passed to server.listen() is the IPv6 wildcard `::` with IPV6_V6ONLY=true. On macOS and Windows, `::` (IPv6-only) and `0.0.0.0` (IPv4) do not conflict, so the daemon's bind succeeded and the assertion failed. Drop the explicit host on the blocker too so it lands on the same default as express.listen(port) — `::` on dual-stack runners.
1 parent 0d90f0f commit 333ece2

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

test/webui/daemon-server.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import { startDaemonServer } from "../../dist/webui/daemon-server.js";
1111
// The contract we want: if the port can't be bound, startDaemonServer must reject.
1212
describe("startDaemonServer bind contract", () => {
1313
it("rejects when the RPC port is already taken (regression for issue #42)", async () => {
14-
// Blocker must bind to 0.0.0.0 because express.listen(port) (no host arg) also
15-
// binds to 0.0.0.0. On BSD-derived stacks (macOS, Windows) a wildcard bind and
16-
// a 127.0.0.1 bind on the same port can coexist, so binding the blocker to
17-
// 127.0.0.1 would let the daemon's wildcard bind succeed and the test wouldn't
18-
// exercise the EADDRINUSE path.
14+
// The blocker must bind the *same way* the daemon does — no host argument —
15+
// so it lands on whatever default Node picks for this platform. On macOS and
16+
// Windows that default is the IPv6 wildcard `::` with IPV6_V6ONLY=true, which
17+
// does NOT conflict with a 0.0.0.0 bind. Binding the blocker to 127.0.0.1 or
18+
// 0.0.0.0 would let the daemon's listen succeed there and never hit EADDRINUSE.
1919
const blocker = net.createServer();
2020
const port = await new Promise<number>((resolve, reject) => {
2121
blocker.once("listening", () => {
@@ -24,7 +24,7 @@ describe("startDaemonServer bind contract", () => {
2424
else reject(new Error(`unexpected address ${JSON.stringify(addr)}`));
2525
});
2626
blocker.once("error", reject);
27-
blocker.listen(0, "0.0.0.0");
27+
blocker.listen(0);
2828
});
2929

3030
// Swallow any stray uncaughtException emitted by an unguarded server.listen()

0 commit comments

Comments
 (0)