From a166a3317a8fef67adc475e1379249c57bafc173 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 03:01:36 +0000 Subject: [PATCH] test(terminal): check original processes after protocol cleanup (#8502) Startup launches another worker after closing obsolete protocols, so a reused numeric PID does not prove the original process survived. Check the recorded birth identities and require cleanup to be confirmed. Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> --- .../terminal/worker-terminal-manager.test.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/server/src/terminal/worker-terminal-manager.test.ts b/packages/server/src/terminal/worker-terminal-manager.test.ts index b0ef983a8e..2a584087a3 100644 --- a/packages/server/src/terminal/worker-terminal-manager.test.ts +++ b/packages/server/src/terminal/worker-terminal-manager.test.ts @@ -1623,13 +1623,26 @@ it.each([1, 4])( async (version) => { const paseoHome = createTemporaryHome(); const old = await leaveWorkerWithTerminal(paseoHome, version); + const [record] = await workerRecords(paseoHome); + const program = record!.terminals.find((entry) => entry.id === old.terminalId)!; + const inspector = createTerminalWorkerProcessInspector(); manager = await startRealWorkerManager({ paseoHome }); - await waitForCondition( - () => !isProcessAlive(old.workerPid) && !isProcessAlive(old.programPid), - 10000, - ); + expect(await readUnconfirmedTerminalCleanup(paseoHome)).toEqual([]); + // Startup launches a replacement worker after cleanup. Either old PID may already + // belong to another process, so verify that the recorded birth identities are gone. + for (const original of [{ pid: record!.pid, ...record!.identity }, program]) { + await expect + .poll( + async () => + !isProcessAlive(original.pid) || + classifyTerminalProgramProcess(original, await inspector.inspect(original.pid)) + .status === "unrelated", + { timeout: 10000 }, + ) + .toBe(true); + } expect(manager.getTerminal(old.terminalId)).toBeUndefined(); const workers = await workerRecords(paseoHome); expect(workers).toHaveLength(1);