diff --git a/packages/core/src/cross-spawn-spawner.ts b/packages/core/src/cross-spawn-spawner.ts index ad8d4126d454..db745a0d5055 100644 --- a/packages/core/src/cross-spawn-spawner.ts +++ b/packages/core/src/cross-spawn-spawner.ts @@ -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 @@ -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) @@ -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(() => { diff --git a/packages/opencode/src/tool/shell.ts b/packages/opencode/src/tool/shell.ts index d3ca542684de..9ed6bdd4d3ef 100644 --- a/packages/opencode/src/tool/shell.ts +++ b/packages/opencode/src/tool/shell.ts @@ -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 }))), ])