diff --git a/packages/core/test/effect/cross-spawn-spawner.test.ts b/packages/core/test/effect/cross-spawn-spawner.test.ts index b81f49e943..1c1ddace47 100644 --- a/packages/core/test/effect/cross-spawn-spawner.test.ts +++ b/packages/core/test/effect/cross-spawn-spawner.test.ts @@ -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) diff --git a/packages/opencode/src/tool/shell.ts b/packages/opencode/src/tool/shell.ts index dda269608e..c9f5416127 100644 --- a/packages/opencode/src/tool/shell.ts +++ b/packages/opencode/src/tool/shell.ts @@ -1,4 +1,4 @@ -import { Effect, Fiber, Stream } from "effect" +import { Effect, Exit, Fiber, Stream } from "effect" import os from "os" import { createWriteStream } from "node:fs" import * as Tool from "./tool" @@ -557,7 +557,7 @@ export const ShellTool = Tool.define( } const outputComplete = yield* Fiber.await(output).pipe( - Effect.as(true), + Effect.map(Exit.isSuccess), Effect.timeoutOrElse({ duration: `${POST_EXIT_OUTPUT_GRACE_MS} millis`, orElse: () => Effect.succeed(false),