Skip to content

Fix Linux desktop bootstrap fd handling#1446

Open
smalitobules wants to merge 1 commit intopingdotgg:mainfrom
smalitobules:fix/linux-desktop-bootstrap
Open

Fix Linux desktop bootstrap fd handling#1446
smalitobules wants to merge 1 commit intopingdotgg:mainfrom
smalitobules:fix/linux-desktop-bootstrap

Conversation

@smalitobules
Copy link

@smalitobules smalitobules commented Mar 26, 2026

Summary

  • fall back to directly reading inherited bootstrap fds when Linux cannot duplicate /proc/self/fd/*
  • guard the Electron desktop bootstrap pipe against unhandled ECONNRESET errors
  • add a regression test for the Linux fallback path

Verification

  • bun run fmt
  • bun run lint
  • bun run typecheck
  • bun run --cwd apps/server test -- src/bootstrap.test.ts
  • bun run --cwd apps/desktop test

Notes

  • apps/server/src/main.test.ts is still blocked locally by a missing node-pty native binary in this environment, separate from this fix.

Note

Medium Risk
Touches desktop↔server bootstrap IPC and file descriptor handling; regressions could prevent the desktop backend from starting on Linux or cause silent startup failures.

Overview
Improves robustness of the desktop backend bootstrap handshake.

On the desktop app, bootstrap envelope writing to the backend pipe is wrapped in a type guard and now attaches an error listener before writing, avoiding unhandled stream errors and failing fast when the bootstrap pipe isn’t writable.

On the server, bootstrap fd reading is refactored into openBootstrapInputStream and now falls back to reading directly from the inherited fd when duplicating /proc/self/fd/* fails with ENXIO (Linux), with a new regression test covering this fallback path.

Written by Cursor Bugbot for commit 8e632a5. This will update automatically on new commits. Configure here.

Note

Fix Linux desktop bootstrap fd handling for writable stream validation and ENXIO fallback

  • Adds isWritableBootstrapStream type guard in main.ts to validate write, end, and once methods before writing; startBackend now kills the child with SIGTERM and schedules a restart if the check fails.
  • Extracts writeBackendBootstrapEnvelope helper that attaches a one-time error listener and writes the JSON envelope, replacing inline logic in startBackend.
  • Adds openBootstrapInputStream in bootstrap.ts that falls back to reading from the inherited fd directly when fd duplication fails with ENXIO, instead of throwing a BootstrapError.
  • Adds a test in bootstrap.test.ts verifying the ENXIO fallback path.

Macroscope summarized 8e632a5.

@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fb04657c-4e57-444d-be58-ee22dfb291e8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant