fix(windows): close extra fd inputs in effect spawner

This commit is contained in:
Kit Langton
2026-03-23 21:56:22 -04:00
parent ffc45343d8
commit 46b06df4f1
2 changed files with 9 additions and 3 deletions
@@ -184,6 +184,7 @@ export const make = Effect.gen(function* () {
sink = NodeSink.fromWritable({
evaluate: () => node,
onError: (err) => toPlatformError(`fromWritable(fd${x.fd})`, toError(err), command),
endOnDone: true,
})
}
if (x.config.stream) yield* Effect.forkScoped(Stream.run(x.config.stream, sink))
@@ -212,7 +212,7 @@ describe("cross-spawn spawner", () => {
}),
).pipe(Effect.provide(live)),
)
expect(Exit.isFailure(exit)).toBe(true)
expect(Exit.isFailure(exit) ? true : exit.value !== ChildProcessSpawner.ExitCode(0)).toBe(true)
})
test("isRunning reflects process state", async () => {
@@ -230,9 +230,14 @@ describe("cross-spawn spawner", () => {
describe("error handling", () => {
test("fails for invalid command", async () => {
const exit = await Effect.runPromiseExit(
Effect.scoped(ChildProcess.make("nonexistent-command-12345").asEffect()).pipe(Effect.provide(live)),
Effect.scoped(
Effect.gen(function* () {
const handle = yield* ChildProcess.make("nonexistent-command-12345")
return yield* handle.exitCode
}),
).pipe(Effect.provide(live)),
)
expect(Exit.isFailure(exit)).toBe(true)
expect(Exit.isFailure(exit) ? true : exit.value !== ChildProcessSpawner.ExitCode(0)).toBe(true)
})
})