Skip to content
8 changes: 6 additions & 2 deletions packages/core/src/cross-spawn-spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ export const make = Effect.gen(function* () {
})
proc.on("exit", (...args) => {
exit = args
if (!end) {
end = true
Deferred.doneUnsafe(signal, Exit.succeed(args))
}
})
proc.on("close", (...args) => {
if (end) return
Expand Down Expand Up @@ -393,7 +397,7 @@ export const make = Effect.gen(function* () {
const escalated = command.options.forceKillAfter
? Effect.timeoutOrElse(attempt, {
duration: command.options.forceKillAfter,
orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
orElse: () => send("SIGKILL"),
})
: attempt
return yield* Effect.ignore(escalated)
Expand Down Expand Up @@ -430,7 +434,7 @@ export const make = Effect.gen(function* () {
if (!opts?.forceKillAfter) return attempt
return Effect.timeoutOrElse(attempt, {
duration: opts.forceKillAfter,
orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
orElse: () => send("SIGKILL"),
})
},
unref: Effect.sync(() => {
Expand Down
5 changes: 4 additions & 1 deletion packages/opencode/src/tool/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ export const ShellTool = Tool.define(
const timeout = Effect.sleep(`${input.timeout + 100} millis`)

const exit = yield* Effect.raceAll([
handle.exitCode.pipe(Effect.map((code) => ({ kind: "exit" as const, code }))),
handle.exitCode.pipe(
Effect.map((code) => ({ kind: "exit" as const, code })),
Effect.catch(() => Effect.succeed({ kind: "exit" as const, code: null })),
),
abort.pipe(Effect.map(() => ({ kind: "abort" as const, code: null }))),
timeout.pipe(Effect.map(() => ({ kind: "timeout" as const, code: null }))),
])
Expand Down
Loading