#4932: fix: add async file-capture fallback for EBADF spawn failures (macOS)
Cluster:
Windows Path and Exec Fixes
## Summary
Fixes #4929 — EBADF spawn failures on macOS cause the gateway to hang.
## Problem
On macOS, `spawn()` can fail with `EBADF` (bad file descriptor) when creating pipes. The previous sync fallback blocked the event loop for up to 5 minutes.
## Solution
- Add async file-capture fallback that uses `stdio: 'ignore'` to bypass pipe creation
- Captures stdout/stderr to temp files, reads them after process exits
- Only triggers on EBADF, normal stdio behavior preserved for all other cases
- macOS only (the EBADF issue is macOS-specific)
## Changes
- `src/process/spawn-utils.ts`: New `createFileCaptureChild()` + `spawnWithFileCapture()` functions
- `src/process/spawn-utils.test.ts`: Tests for fallback behavior
## Testing
- All existing tests pass
- Tested on affected macOS machine with high fallback rate
- Commands complete successfully with ~35-40ms latency via fallback
Most Similar PRs
#8038: fix(exec): use spawnWithFallback to handle EBADF on macOS
by FelixFoster · 2026-02-03
72.3%
#22721: fix(exec): keep child runs attached on macOS for reliable output
by rylena · 2026-02-21
65.1%
#6577: fix: add null checks for stdout/stderr when using inherit-stdio fal...
by ncmalan · 2026-02-01
62.3%
#22355: fix(gateway): add exponential backoff to remote node bin probes
by xinhuagu · 2026-02-21
60.1%
#17929: fix(skills): augment PATH with /etc/paths on macOS for binary detec...
by lailoo · 2026-02-16
59.3%
#22813: Return clear error when exec cwd is missing instead of spawn ENOENT
by Clawborn · 2026-02-21
59.2%
#19391: fix(process): destroy stdio streams on dispose and terminate childr...
by nabbilkhan · 2026-02-17
59.2%
#6273: fix: handle EPIPE errors gracefully in daemon operations
by batumilove · 2026-02-01
59.2%
#9250: Fix: Add shell:true for Windows .cmd files to prevent spawn EINVAL ...
by vishaltandale00 · 2026-02-05
58.7%
#19063: CI/macOS: disable Vitest vmForks for TS tests to stop mock-state le...
by agisilaos · 2026-02-17
58.0%