diff options
| author | Luke Parker <[email protected]> | 2026-04-10 10:00:46 +1000 |
|---|---|---|
| committer | opencode <[email protected]> | 2026-04-10 01:00:21 +0000 |
| commit | 98874a09f76402e9bdc5df197faab24f4e477c2f (patch) | |
| tree | 0d746dc8fbe13fcdb5dc305480a80bd35472cc79 | |
| parent | 877be7e8e04142cd8fbebcb5e6c4b9617bf28cce (diff) | |
| download | opencode-98874a09f76402e9bdc5df197faab24f4e477c2f.tar.gz opencode-98874a09f76402e9bdc5df197faab24f4e477c2f.zip | |
fix windows e2e backend not stopping on sigterm waiting 10s for no reason (#21781)
| -rw-r--r-- | packages/app/e2e/backend.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/app/e2e/backend.ts b/packages/app/e2e/backend.ts index 9febc4b3f..a03d1d437 100644 --- a/packages/app/e2e/backend.ts +++ b/packages/app/e2e/backend.ts @@ -44,8 +44,12 @@ async function waitForHealth(url: string, probe = "/global/health") { throw new Error(`Timed out waiting for backend health at ${url}${probe}${last ? ` (${last})` : ""}`) } +function done(proc: ReturnType<typeof spawn>) { + return proc.exitCode !== null || proc.signalCode !== null +} + async function waitExit(proc: ReturnType<typeof spawn>, timeout = 10_000) { - if (proc.exitCode !== null) return + if (done(proc)) return await Promise.race([ new Promise<void>((resolve) => proc.once("exit", () => resolve())), new Promise<void>((resolve) => setTimeout(resolve, timeout)), @@ -123,11 +127,11 @@ export async function startBackend(label: string, input?: { llmUrl?: string }): return { url, async stop() { - if (proc.exitCode === null) { + if (!done(proc)) { proc.kill("SIGTERM") await waitExit(proc) } - if (proc.exitCode === null) { + if (!done(proc)) { proc.kill("SIGKILL") await waitExit(proc) } |
