Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,16 @@ async function main(): Promise<void> {
}
})

// Wait until stdin closes (parent terminates or closes the pipe)
await new Promise<void>((resolve) => rl.once("close", resolve))
// Wait until stdin closes (parent terminates or closes the pipe).
// Abort the crawl so run()'s disconnect-wait breaks and the worker exits cleanly.
await new Promise<void>((resolve) =>
rl.once("close", () => {
controller.abort()
resolve()
}),
)
// Backstop: if runWorker is still hanging 5s after stdin close, force exit
setTimeout(() => process.exit(0), 5000).unref()
}

async function runWorker(opts: WorkerOptions, signal: AbortSignal): Promise<void> {
Expand Down
10 changes: 9 additions & 1 deletion packages/cyberstrike/src/tool/hackbrowser-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ async function backgroundRun(
}

// Worker exited without sending result/error — unexpected crash.
// Force-kill to clean up any orphaned Chrome child processes.
if (!receivedResult) {
try { proc.kill() } catch {}
const exitCode = await proc.exited.catch(() => -1)
const stderr = await Bun.readableStreamToText(proc.stderr as ReadableStream).catch(() => "")
const message =
Expand Down Expand Up @@ -463,7 +465,13 @@ async function backgroundRun(
)
} finally {
activeRuns.delete(sessionID)
proc.kill()
try {
const s = proc.stdin
if (s && typeof s !== "number") (s as any).end()
} catch {}
setTimeout(() => {
try { proc.kill() } catch {}
}, 10_000)
}
}

Expand Down
Loading
Loading