From 43ef214fc11b0565c4d24e5287b0673b0c872e28 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 5 Nov 2026 06:04:28 +0100 Subject: [PATCH] test(terminal): fail the worker launch the same way on every platform Windows opens a directory sitting at the launcher's log path, so the worker started there and the #8810 test never saw a failed launch. An invalid protocol override makes the worker exit before it writes its record on every platform. --- .../terminal/worker-terminal-manager.test.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/server/src/terminal/worker-terminal-manager.test.ts b/packages/server/src/terminal/worker-terminal-manager.test.ts index adf7ce6517..214c8fb4c6 100644 --- a/packages/server/src/terminal/worker-terminal-manager.test.ts +++ b/packages/server/src/terminal/worker-terminal-manager.test.ts @@ -61,7 +61,6 @@ import { listTerminalWorkerRecords, readTerminalWorkerRecord, terminalWorkerDirectory, - terminalWorkerLogPath, terminalWorkerRecordPath, writeTerminalWorkerRecord, type TerminalWorkerRecord, @@ -2679,20 +2678,23 @@ it.each([false, true])( 45000, ); -// #8810: a worker that cannot start must not take the daemon down. The launcher cannot open its -// log here (a directory sits at its path), so the launch fails before any worker runs. +// #8810: a worker that cannot start must not take the daemon down. An override that is not a +// protocol version makes the worker fail before it writes its record, on every platform. it("starts without a worker when the worker cannot start, and launches one once it can", async () => { const paseoHome = createTemporaryHome(); - const logPath = terminalWorkerLogPath(paseoHome); - mkdirSync(logPath); + const previous = process.env[TERMINAL_WORKER_PROTOCOL_OVERRIDE_ENV]; + process.env[TERMINAL_WORKER_PROTOCOL_OVERRIDE_ENV] = "not-a-version"; + try { + manager = await startRealWorkerManager({ paseoHome }); + expect(await workerRecords(paseoHome)).toEqual([]); + await expect( + manager.createTerminal({ workspaceId: "ws-no-worker", cwd: paseoHome }), + ).rejects.toThrow(TerminalWorkerLaunchError); + } finally { + if (previous === undefined) delete process.env[TERMINAL_WORKER_PROTOCOL_OVERRIDE_ENV]; + else process.env[TERMINAL_WORKER_PROTOCOL_OVERRIDE_ENV] = previous; + } - manager = await startRealWorkerManager({ paseoHome }); - expect(await workerRecords(paseoHome)).toEqual([]); - await expect( - manager.createTerminal({ workspaceId: "ws-no-worker", cwd: paseoHome }), - ).rejects.toThrow(TerminalWorkerLaunchError); - - rmSync(logPath, { recursive: true }); trackTerminal(await manager.createTerminal({ workspaceId: "ws-no-worker", cwd: paseoHome })); expect(await workerRecords(paseoHome)).toHaveLength(1); }, 30000);