← Back to PRs

#4932: fix: add async file-capture fallback for EBADF spawn failures (macOS)

by Oceanswave open 2026-01-30 21:27 View on GitHub →
## 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