fix(opencode): handle shell capture failures

This commit is contained in:
Hona 2026-07-21 01:11:33 +00:00
commit 82565bf336
2 changed files with 11 additions and 10 deletions

View file

@ -305,20 +305,21 @@ describe("cross-spawn spawner", () => {
`writeFileSync(${JSON.stringify(file)}, String(child.pid))`,
].join("\n"),
])
yield* Effect.addFinalizer(() =>
Effect.promise(async () => {
const pid = Number(await fs.readFile(file, "utf8").catch(() => ""))
if (!pid) return
try {
process.kill(pid, "SIGKILL")
} catch {}
}),
)
const code = yield* handle.exitCode.pipe(
Effect.timeoutOrElse({
duration: "2 seconds",
orElse: () => Effect.die("exitCode waited for inherited output pipes"),
}),
)
const pid = Number(yield* Effect.promise(() => fs.readFile(file, "utf8")))
yield* Effect.addFinalizer(() =>
Effect.sync(() => {
try {
process.kill(pid, "SIGKILL")
} catch {}
}),
)
expect(code).toBe(ChildProcessSpawner.ExitCode(0))
expect(yield* handle.isRunning).toBe(false)