fix(opencode): handle shell capture failures
This commit is contained in:
parent
9e883bfebf
commit
82565bf336
2 changed files with 11 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue