fix(opencode): handle shell capture failures
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user