Skip to content

Commit 7a282f9

Browse files
committed
fix(util): type a synchronous spawn refusal through the PlatformError channel
launch() can throw synchronously (e.g. EPERM from uv_spawn on Windows); launchProcess only mapped the async error event to a PlatformError, so the throw escaped the Effect.callback as a defect that no caller's typed-failure handling sees — the failure mode behind the Snapshot.capture step death in anomalyco#58685. Wrap the launch call and resume through the same toPlatformError path, so every caller gets the typed failure its handlers already recover. Reviewed-by-direction from the anomalyco#58722 review thread; implementation shape credited to r266-tech's retained patch.
1 parent 17f9662 commit 7a282f9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/util/src/cross-spawn-spawner.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,16 @@ const makeCrossSpawnSpawner = Effect.gen(function* () {
280280
Effect.callback<Spawned, PlatformError.PlatformError>((resume) => {
281281
const closed = Deferred.makeUnsafe<readonly [code: number | null, signal: NodeJS.Signals | null]>()
282282
const exited = Deferred.makeUnsafe<readonly [code: number | null, signal: NodeJS.Signals | null]>()
283-
const proc = launch(command.command, command.args, opts)
283+
// A spawn refusal (e.g. EPERM from uv_spawn) throws synchronously; only the async `error` event
284+
// reaches the typed handler below, so map the throw through the same PlatformError here — otherwise
285+
// it escapes the callback as a defect and no caller's typed-failure handling sees it.
286+
let proc: NodeChildProcess.ChildProcess
287+
try {
288+
proc = launch(command.command, command.args, opts)
289+
} catch (err) {
290+
resume(Effect.fail(toPlatformError("spawn", toError(err), command)))
291+
return Effect.void
292+
}
284293
let end = false
285294
let exit: readonly [code: number | null, signal: NodeJS.Signals | null] | undefined
286295
proc.on("error", (err) => {

0 commit comments

Comments
 (0)