Fix server fallback to direct fd read on /proc/self/fd failure#1488
Fix server fallback to direct fd read on /proc/self/fd failure#1488juliusmarminge merged 4 commits intopingdotgg:mainfrom
Conversation
On some Linux environments (containers, restricted kernels), `/proc/self/fd/<n>` exists but cannot be opened, returning ENXIO, EINVAL, or EPERM. Previously this would surface as a hard BootstrapError. Now the server falls back to reading the fd directly, matching the behavior already used on Windows. Also prefers `fs.createReadStream` over `net.Socket` for the direct fd path, as it is better behaved for regular file descriptors.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
@Ivorisnoob iirc you recommended using |
one minute let me checkout this |
|
Ah right, @juliusmarminge my Net.Socket suggestion was only meant for the Windows pipe case, should've been clearer about that. fs.createReadStream is the better default here since it handles both regular fds and pipes without complaining (unlike Net.Socket which throws ERR_INVALID_FD_TYPE on regular file fds). The PR overall looks solid to me. The ENXIO/EINVAL/EPERM catch on the /proc/self/fd path is a real fix for restricted Linux environments and the fallback chain makes sense. Nice one 👍 |
- Wrap the `openSync` ENXIO guard across multiple lines - Keep the Linux fd failure test stable and readable

What Changed
On some Linux environments (containers, restricted kernels),
/proc/self/fd/<n>exists but cannot be opened, returning ENXIO, EINVAL, or EPERM. Previously this would surface as a hard BootstrapError. Now the server falls back to reading the fd directly, matching the behavior already used on Windows.Also prefers
fs.createReadStreamovernet.Socketfor the direct fd path, as it is better behaved for regular file descriptors.Why
I tried to launch the app via code on my linux (pop os) machine and was facing an error. Fixed the error and everything looks good now
UI Changes
Checklist
Note
Medium Risk
Medium risk because it changes how bootstrap data is read from inherited file descriptors and adjusts fd/stream ownership (
autoClose), which can affect startup behavior and resource lifecycles on Linux.Overview
Fixes server bootstrap reads in restricted Linux environments by falling back to reading directly from the inherited fd when opening
/proc/self/fd/<n>fails withENXIO/EINVAL/EPERM, instead of throwing aBootstrapError.Refactors direct-fd handling to prefer
fs.createReadStream(withautoClose: true) and only fall back tonet.Socketif stream creation fails, and adds a unit test that mocksfs.openSyncto force the duplication-failure path and assert the fallback behavior.Written by Cursor Bugbot for commit 286e7c2. This will update automatically on new commits. Configure here.
Note
Fix server bootstrap to fall back to direct fd read when
/proc/self/fdduplication fails/proc/self/fd/<n>) fails withENXIO,EINVAL, orEPERM,makeBootstrapInputStreamnow falls back to reading directly from the inherited fd instead of throwing.makeDirectBootstrapStreamwhich prefersNFS.createReadStreamwithautoClose: true, falling back to aNet.Socketonly if stream creation throws.isBootstrapFdPathDuplicationErrorpredicate to distinguish recoverable fd-duplication errors from other failures.createReadStreambeforeNet.Socket, reversing the previous preference order.Macroscope summarized 286e7c2.