From 47189a18e2ce4569a46844d483446b2cc1992b2f Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Tue, 24 Nov 2026 23:54:11 -0800 Subject: [PATCH] Stop the QA-only cleanup test from failing at random on a fast terminal-agent exit (GST-3830) (#4823) The QA-only cleanup test's missing-terminal case now waits for the terminal agent to publish its port before it deletes the agent's record, so it no longer fails at random in CI. Why: a red test should mean something broke, and this race turned the merged-tree check for #4803 red twice in a row. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- changelog.d/fix-qa-cleanup-missing-terminal-race.md | 1 + test/qa-only-cleanup.test.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fix-qa-cleanup-missing-terminal-race.md diff --git a/changelog.d/fix-qa-cleanup-missing-terminal-race.md b/changelog.d/fix-qa-cleanup-missing-terminal-race.md new file mode 100644 index 000000000..f58aa21ba --- /dev/null +++ b/changelog.d/fix-qa-cleanup-missing-terminal-race.md @@ -0,0 +1 @@ +**The QA-only cleanup test no longer fails at random in CI.** Its missing-terminal case now waits until the terminal agent has published its port before removing the agent's record, so it always checks that cleanup refuses when a terminal's record is gone but its port file is left behind. diff --git a/test/qa-only-cleanup.test.ts b/test/qa-only-cleanup.test.ts index 08ef76725..3d9c3c87e 100644 --- a/test/qa-only-cleanup.test.ts +++ b/test/qa-only-cleanup.test.ts @@ -106,6 +106,7 @@ fs.writeFileSync(${JSON.stringify(path.join(dir, 'port'))}, String(server.port)) restore = () => spy.mockRestore(); } if (scenario === 'missing-terminal') { + await waitFor(() => fs.existsSync(path.join(stateDir, 'terminal-port'))); fs.unlinkSync(agentFile); fs.writeFileSync(path.join(stateDir, 'browse-daemon.log'), '[browse] terminal-agent exit remains unconfirmed: fixture\n'); } @@ -134,7 +135,7 @@ Bun.spawnSync = (...args) => { const started = performance.now(); const errors = { 'ack-only': 'settlement deadline exceeded', 'replaced-state': 'daemon state was replaced', 'terminal-mismatch': 'terminal ownership is unconfirmed', 'chromium-mismatch': 'Chromium ownership is unconfirmed', - 'missing-terminal': /terminal identity is unavailable \(record absent; terminal-port .*daemon log terminal-agent lines: \[browse\] terminal-agent exit remains unconfirmed: fixture\)/, + 'missing-terminal': /terminal identity is unavailable \(record absent; terminal-port present; .*daemon log terminal-agent lines: \[browse\] terminal-agent exit remains unconfirmed: fixture\)/, 'unrecorded-terminal': new RegExp(`terminal identity is unavailable \\(record absent; terminal-port absent; running fixture agents: ${stray?.pid}; daemon ${daemon.pid} alive`), 'unlisted-agents': 'terminal agent identities are unavailable', 'blocked-identity': 'owned worker settlement deadline exceeded' };