Skip to content

Commit 98874a0

Browse files
Honaopencode
authored andcommitted
fix windows e2e backend not stopping on sigterm waiting 10s for no reason (#21781)
1 parent 877be7e commit 98874a0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/app/e2e/backend.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ async function waitForHealth(url: string, probe = "/global/health") {
4444
throw new Error(`Timed out waiting for backend health at ${url}${probe}${last ? ` (${last})` : ""}`)
4545
}
4646

47+
function done(proc: ReturnType<typeof spawn>) {
48+
return proc.exitCode !== null || proc.signalCode !== null
49+
}
50+
4751
async function waitExit(proc: ReturnType<typeof spawn>, timeout = 10_000) {
48-
if (proc.exitCode !== null) return
52+
if (done(proc)) return
4953
await Promise.race([
5054
new Promise<void>((resolve) => proc.once("exit", () => resolve())),
5155
new Promise<void>((resolve) => setTimeout(resolve, timeout)),
@@ -123,11 +127,11 @@ export async function startBackend(label: string, input?: { llmUrl?: string }):
123127
return {
124128
url,
125129
async stop() {
126-
if (proc.exitCode === null) {
130+
if (!done(proc)) {
127131
proc.kill("SIGTERM")
128132
await waitExit(proc)
129133
}
130-
if (proc.exitCode === null) {
134+
if (!done(proc)) {
131135
proc.kill("SIGKILL")
132136
await waitExit(proc)
133137
}

0 commit comments

Comments
 (0)