From f9357abaf329ebb23aa97d0059b7fbca94603d99 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:43:30 +0000 Subject: [PATCH] test(terminal): retain startup phases on launch failure --- .../src/terminal/terminal-worker-launch.ts | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/server/src/terminal/terminal-worker-launch.ts b/packages/server/src/terminal/terminal-worker-launch.ts index 573abe3bd8..e0f7939abc 100644 --- a/packages/server/src/terminal/terminal-worker-launch.ts +++ b/packages/server/src/terminal/terminal-worker-launch.ts @@ -1,10 +1,12 @@ import { execFile } from "node:child_process"; import { randomUUID } from "node:crypto"; +import { readFile, readdir } from "node:fs/promises"; import { buildSelfNodeCommand } from "../server/paseo-env.js"; import { ensurePrivateDirectory } from "../server/private-files.js"; import { readTerminalWorkerRecord, terminalWorkerDirectory, + terminalWorkerLogPath, terminalWorkerRecordPath, type TerminalWorkerRecord, } from "./terminal-worker-record.js"; @@ -56,13 +58,31 @@ export async function launchTerminalWorker(input: { windowsHide: true, encoding: "utf8", }, - (error, out, err) => { + async (error, out, err) => { if (error) { const detail = err.trim() || error.message; + // Temporary diagnostics: retain the last startup stage before test cleanup removes it. + let startup = ""; + try { + startup = (await readFile(terminalWorkerLogPath(input.paseoHome), "utf8")) + .split("\n") + .filter((line) => line.startsWith('{"phase":')) + .slice(-12) + .join("\n"); + const records = (await readdir(terminalWorkerDirectory(input.paseoHome))).filter( + (name) => name.endsWith(".json"), + ).length; + startup += `\nWorker records at failure: ${records}`; + } catch { + startup += "\nStartup diagnostics unavailable"; + } reject( - new TerminalWorkerLaunchError(`Terminal worker failed to start: ${detail}`, { - cause: error, - }), + new TerminalWorkerLaunchError( + `Terminal worker failed to start: ${detail}\n${startup}`, + { + cause: error, + }, + ), ); return; }