You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky: server-auto-open.test.ts races for its port and process.exit(1)s under load #2602
clients/web/src/test/integration/server/server-auto-open.test.ts gets its port from findFreePort(). That helper binds :0, reads the port, closes the socket, and returns the number. startHonoServer then binds that port later. Between the close and the bind, any other process on the machine can take the port.
When that happens, httpServer.on("error") in clients/web/server/server.ts:166 sees EADDRINUSE and calls process.exit(1). Under vitest that surfaces as process.exit unexpectedly called with "1", plus a failed keeps serving when the browser cannot be opened, and it fails npm run local:gate.
Reproduce
This depends on load: it needs several worktrees running suites at the same time, which is the normal setup here. It happened once in a full local:gate while I was working on #2437 (gate7.log, coverage stage). Run alone, the file passed 5/5.
Error: process.exit unexpectedly called with "1"
❯ Server.<anonymous> server/server.ts:171:15
❯ emitErrorNT node:net:1970:8
AssertionError: expected "vi.fn()" to be called with arguments: [ StringContaining{…} ]
142| expect(warn).toHaveBeenCalledWith(WARNING, expect.any(Error));
Expected
The test owns its port from the moment it picks it, so the suite can't go red because of what other processes are doing.
Possible fix
Have the server bind port: 0 itself and read back the port it actually got, the same way the harnesses in integration/mcp/remote/ do. That needs startHonoServer to accept 0 and report its bound port, if it doesn't already. Failing that, retry the start on EADDRINUSE inside the test. Either way this is a fix to the test, not to server.ts's handling of a port that really is taken (#1090).
Activity
test(web): bind auto-open server to :0 instead of probing a free port (…