mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-19 21:32:20 +03:00
Fix correto — CLI agora sonda IPv4 e IPv6 no probe de prontidão do servidor, com teste de regressão próprio (`tests/unit/cli-waitForServer.test.mjs`). Validado no worktree combinado (typecheck limpo, teste focado verde). Obrigado!
This commit is contained in:
@@ -11,6 +11,7 @@ import { waitForServer } from "../../bin/cli/utils/pid.mjs";
|
||||
// listening, and (d) return false when the port merely accepts TCP and then
|
||||
// hangs without ever answering a request (#6800 — a still-booting/CPU-bound
|
||||
// process must NOT be reported as ready just because the socket is open).
|
||||
// #11766: also test that IPv6 loopback is checked when IPv4 is unavailable.
|
||||
|
||||
async function freePort() {
|
||||
return new Promise((resolve) => {
|
||||
@@ -77,3 +78,32 @@ test("waitForServer returns false when the port accepts TCP but never answers a
|
||||
await new Promise((resolve) => server.close(() => resolve()));
|
||||
}
|
||||
});
|
||||
|
||||
test("waitForServer detects IPv6 loopback health endpoint when IPv4 is unavailable (#11766)", async () => {
|
||||
const port = await freePort();
|
||||
const server = net.createServer((socket) => {
|
||||
socket.on("data", (data) => {
|
||||
const request = data.toString();
|
||||
if (request.includes("GET /api/monitoring/health")) {
|
||||
socket.end("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nok");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Listen only on IPv6 loopback
|
||||
await new Promise((resolve, reject) => {
|
||||
server.once("error", reject);
|
||||
server.listen(port, "::1", () => resolve());
|
||||
});
|
||||
|
||||
try {
|
||||
const result = await waitForServer(port, 8000);
|
||||
assert.equal(
|
||||
result,
|
||||
true,
|
||||
"expected waitForServer to detect health endpoint on IPv6 loopback even when IPv4 is unavailable"
|
||||
);
|
||||
} finally {
|
||||
await new Promise((resolve) => server.close(() => resolve()));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user