fix(desktop): prevent WSL backend exiting with code 0 by keeping stdi…#3613
fix(desktop): prevent WSL backend exiting with code 0 by keeping stdi…#3613jibin7jose wants to merge 13 commits into
Conversation
…n open Fixes pingdotgg#3611 by appending Stream.never to the bootstrap stream so the Windows-side pipe does not close before the backend process completes reading it.
|
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 |
ApprovabilityVerdict: Needs human review This PR introduces new runtime behavior for WSL backend lifecycle: stdin stream handling changes, new failure tracking with fallback logic after consecutive never-ready exits, and Node.js version validation. These are meaningful behavioral changes to backend management that warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Tests using fd3 delivery were hanging because the stream never terminated. Only stdin delivery (WSL) needs the stream kept open.
…gg#3611) Consolidates fixes from PRs pingdotgg#3613, pingdotgg#3621, and pingdotgg#3623 to address both root causes and add a fail-safe: 1. DesktopWslEnvironment: Parse the Node version in the WSL node-pty probe and validate it against options.nodeEngineRange. Preflight now fails cleanly with an actionable error if the distro's default Node is incompatible. 2. DesktopBackendManager: Track neverReadyAttempt to cap consecutive post-spawn exits on stdin delivery. Prevents the desktop from permanently getting stuck restarting if the WSL backend consistently fails before readiness. 3. bootstrap: Clean up the readline interface on all event paths to prevent leaks when stdin stays open, and register the error listener on the readline interface to safely catch early stream errors.
340fb76 to
215bd10
Compare
Dismissing prior approval to re-evaluate 215bd10
|
@juliusmarminge Could you please approve the workflows for this PR so the checks can run? Thank you! |
|
Hi @juliusmarminge! When you have time, could you please take a look at this PR? It addresses issue #3611 by fixing the WSL backend exiting early when using stdin bootstrap delivery. I’ve incorporated the follow-up fixes and kept the PR up to date with main. If you have any feedback or would like any changes, I’d be happy to update the PR. Thank you! |
|
Hi @juliusmarminge, @t3dotgg, and @codex! When you have a chance, could you please take a look at this PR? It fixes the WSL backend exiting early when using stdin bootstrap delivery, includes the follow-up fixes from earlier feedback, and has been kept up to date with main. Once the workflows are approved and the checks complete, I'd really appreciate your review. Thank you! |
|
To use Codex here, create a Codex account and connect to github. |
…n open
Fixes #3611 by appending Stream.never to the bootstrap stream so the Windows-side pipe does not close before the backend process completes reading it.
What Changed
Why
UI Changes
Checklist
Note
Medium Risk
Touches desktop backend spawn/restart lifecycle and WSL preflight gating; changes are scoped but affect when the app falls back from WSL and how bootstrap is read over stdin.
Overview
Fixes WSL backends exiting with code 0 right after bootstrap by appending
Stream.neverto the stdin bootstrap stream so the Windows-side pipe stays open until the child finishes reading the envelope (stdin-delivery only; fd3 Windows-native unchanged).Adds a
neverReadyAttemptcounter for stdin-delivery backends that tracks consecutive exits before HTTP readiness. AfterMAX_PREFLIGHT_FAILURE_ATTEMPTS, the manager callsonPreflightFailedand stops or restarts based on its result instead of looping forever; successful readiness resets the counter.WSL preflight now prints
nodeVersion:from the node-pty probe andparseNodeVersionvalidates it againstnodeEngineRange, failing fast with a fatal, actionable error when Node is missing or incompatible.Server
readBootstrapEnveloperegisters theerrorlistener on the readline interface (not the raw stream) and runscleanupon error, line, and close so early stream errors are handled consistently.Reviewed by Cursor Bugbot for commit 0b8f928. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix WSL backend exiting prematurely by keeping stdin open for stdin-delivery backends
Stream.never, preventing the child process from exiting with code 0 immediately after receiving its envelope.neverReadyAttemptcounter; afterMAX_PREFLIGHT_FAILURE_ATTEMPTS,onPreflightFailedis invoked and the manager stops or restarts based on its result rather than restarting indefinitely.nodeVersion:line;ensureNodePtyImplvalidates this against a supplied semver range and returns{ ok: false, fatal: true }when the version is missing or out of range.readBootstrapEnvelopeis fixed to register theerrorlistener on the readline interface rather than the raw stream, ensuring cleanup runs on all error paths.Macroscope summarized 0b8f928.