From d102cd59a9f5b324bd2255163d6be2e06edae954 Mon Sep 17 00:00:00 2001 From: Chris Scott <> Date: Thu, 15 Oct 2026 17:54:38 +0000 Subject: [PATCH 1/2] test(backend): isolate sandbox env and bound OpenCode stop in binary-backed tests --- backend/test/helpers/opencode-binary.ts | 8 ++++++-- backend/test/setup.ts | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/test/helpers/opencode-binary.ts b/backend/test/helpers/opencode-binary.ts index a47e5e794..f52cf720e 100644 --- a/backend/test/helpers/opencode-binary.ts +++ b/backend/test/helpers/opencode-binary.ts @@ -13,7 +13,8 @@ const VERSION_TIMEOUT_MS = 5000 const SERVE_READY_TIMEOUT_MS = 60000 const SERVE_POLL_INTERVAL_MS = 250 const RUN_TIMEOUT_MS = 90000 -const STOP_TIMEOUT_MS = 10000 +const STOP_TIMEOUT_MS = 5000 +const KILL_CONFIRM_MS = 2000 const OPENCODE_BINARY_CANDIDATES = ['opencode', '/usr/local/bin/opencode', '/opt/opencode/bin/opencode'] @@ -205,7 +206,10 @@ export async function startOpenCodeServe(options: OpenCodeServeOptions = {}): Pr if (child.exitCode === null && child.signalCode === null) { child.kill('SIGTERM') await Promise.race([once(child, 'close'), delay(STOP_TIMEOUT_MS)]) - if (child.exitCode === null && child.signalCode === null) child.kill('SIGKILL') + if (child.exitCode === null && child.signalCode === null) { + child.kill('SIGKILL') + await Promise.race([once(child, 'close'), delay(KILL_CONFIRM_MS)]) + } } } diff --git a/backend/test/setup.ts b/backend/test/setup.ts index 77229b1b5..66fd87806 100644 --- a/backend/test/setup.ts +++ b/backend/test/setup.ts @@ -1,5 +1,9 @@ import { beforeAll, afterAll } from 'vitest' +for (const key of Object.keys(process.env)) { + if (key !== 'MSB_PATH' && /^(SANDBOX|MSB)_/.test(key)) delete process.env[key] +} + const originalEnv: Record = {} beforeAll(() => { From 6ee719cf1bc37fd9619dcee270b2a6028c804bb0 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:58:21 -0400 Subject: [PATCH 2/2] fix: apply CodeRabbit auto-fixes --- backend/test/helpers/opencode-binary.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/test/helpers/opencode-binary.ts b/backend/test/helpers/opencode-binary.ts index f52cf720e..ad62d80b2 100644 --- a/backend/test/helpers/opencode-binary.ts +++ b/backend/test/helpers/opencode-binary.ts @@ -223,8 +223,11 @@ export async function startOpenCodeServe(options: OpenCodeServeOptions = {}): Pr readOutput: () => output, terminate, stop: async () => { - await terminate() - await removeOwnedDirectories() + try { + await terminate() + } finally { + await removeOwnedDirectories() + } }, } }