From cfefdbdb938619a02fc4234e99f1dd08eadd5304 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:09:22 +0000 Subject: [PATCH] test(terminal): trace intermittent worker startup timeouts --- .../src/terminal/terminal-worker-process.ts | 9 +++++++++ .../src/terminal/worker-terminal-manager.test.ts | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/server/src/terminal/terminal-worker-process.ts b/packages/server/src/terminal/terminal-worker-process.ts index 855c39da59..6a20d3504d 100644 --- a/packages/server/src/terminal/terminal-worker-process.ts +++ b/packages/server/src/terminal/terminal-worker-process.ts @@ -169,6 +169,9 @@ function runLauncher(argv: string[]): void { type TerminalCreateRequest = Extract; function runWorker(argv: string[]): void { + const startupPhase = (phase: string) => + console.error(JSON.stringify({ phase, uptimeMs: Math.round(process.uptime() * 1000) })); + startupPhase("worker-modules-loaded"); const args = parseWorkerArgs(argv, TERMINAL_WORKER_MARKER_ARG); const protocolVersion = reportedProtocolVersion(); const manager = createTerminalManager(); @@ -686,6 +689,7 @@ function runWorker(argv: string[]): void { writeSync(READY_FD, `${line}\n`); closeSync(READY_FD); } catch { + startupPhase("ready-write-failed"); // Started without a launcher pipe (tests that spawn the worker directly). } } @@ -707,11 +711,14 @@ function runWorker(argv: string[]): void { }); }); server = listening; + startupPhase("socket-listening"); if (process.platform !== "win32") { chmodSync(socketPath, PRIVATE_FILE_MODE); } + startupPhase("identity-start"); const self = await inspector.inspect(process.pid); + startupPhase("identity-finished"); if ( self.status !== "alive" || !self.snapshot.startedAt || @@ -734,7 +741,9 @@ function runWorker(argv: string[]): void { terminals: [], }; writeTerminalWorkerRecord(args.paseoHome, record); + startupPhase("record-written"); reportReady(`ready ${socketPath}`); + startupPhase("ready-reported"); setTimeout(() => { if (!everControlled && sessionsById.size === 0) exitWorker(0); diff --git a/packages/server/src/terminal/worker-terminal-manager.test.ts b/packages/server/src/terminal/worker-terminal-manager.test.ts index 2a584087a3..0512a0b092 100644 --- a/packages/server/src/terminal/worker-terminal-manager.test.ts +++ b/packages/server/src/terminal/worker-terminal-manager.test.ts @@ -2671,3 +2671,19 @@ it.each([false, true])( }, 45000, ); + +it.skipIf(process.platform !== "win32").each(Array.from({ length: 40 }, (_, i) => i + 1))( + "diagnostic: fresh terminal worker startup %i", + async () => { + const paseoHome = createTemporaryHome(); + const started = Date.now(); + try { + manager = await startRealWorkerManager({ paseoHome }); + expect(manager).toBeDefined(); + } finally { + console.log("terminal startup duration", Date.now() - started); + const workerLog = join(paseoHome, "terminal-worker.log"); + if (existsSync(workerLog)) console.log(readFileSync(workerLog, "utf8")); + } + }, +);