fix(desktop): keep probing backend readiness while the process is alive - #5526
fix(desktop): keep probing backend readiness while the process is alive#5526lgwacker wants to merge 3 commits into
Conversation
The desktop probed /.well-known/t3/environment exactly once with a fixed 60s budget. When the WSL backend cold-boots slower than that (server bundle loading across /mnt/c, or a first launch right after an update), the probe gave up permanently and the app stayed stuck on "Connecting to WSL…" forever even though the backend kept running and became healthy moments later. runBackendProcess now re-probes readiness in a loop while the child is still alive: each round gets a fresh budget, onReadinessFailure fires per round, and the loop is torn down with the run scope when the child exits. Model: DeepSeek (opencode-go/deepseek-v4-flash) via opencode.
|
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 Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 bug fix changes backend readiness probing from one-shot to continuous retry, which modifies core startup behavior. The fix is well-tested and localized, but the author is new to this area of the codebase and the change affects backend lifecycle management - warrants human review. You can customize Macroscope's approvability policy. Learn more. |
What Changed
runBackendProcess(apps/desktop/src/backend/DesktopBackendManager.ts) now probes backend readiness in a loop while the child process is still alive, instead of probing exactly once with a fixed 60s budget and then never retrying.Each round gets a fresh readiness budget; on timeout,
onReadinessFailurefires and the loop immediately starts another round; the loop stops on success or is torn down with the run scope when the child exits. Behavior is unchanged when the backend becomes ready within the first budget.Why
The readiness probe was one-shot: after the 60s budget expired, the app never probed again even though the backend process kept running and became healthy ~20s later. A slow WSL cold boot (server bundle loading across
/mnt/c, or a first launch right after an update — cold Windows file cache + Defender re-scan) routinely exceeds that budget, so wsl-only users were left stuck on the "Connecting to WSL…" splash forever with no retry and no recovery path. This is the failure documented in #4535 and filed as #5522. It makes the app resilient regardless of how long boot takes, without widening the budget or changing the fast-path.UI Changes
None.
Checklist
Fixes #5522
Note
Medium Risk
Changes desktop backend startup and readiness signaling; behavior is covered by a new test but repeated timeouts could increase log/snapshot noise until the backend is healthy.
Overview
runBackendProcessno longer treats backend HTTP readiness as a single attempt with one timeout. It loopswaitForHttpReadyin a scoped fiber until the health endpoint returns success or the child exits.Each iteration gets a fresh readiness budget. A timeout still invokes
onReadinessFailure, then probing continues instead of stopping permanently—addressing slow WSL cold boots that outlast the first budget while the backend process keeps running.Fast paths are unchanged when the backend becomes ready within the first budget. A new test asserts re-probing across multiple expired budgets before a late 200 response.
Reviewed by Cursor Bugbot for commit 22821ba. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
runBackendProcessto keep probing backend readiness while the process is alivePreviously,
runBackendProcessstopped probing after the first readiness timeout. It now loops, callingwaitForHttpReadyrepeatedly across successive timeout budgets until the backend responds with HTTP 200, invokingonReadinessFailureon each failed attempt andonReadyonce on success. A new internal effectdesktop.backendProcess.probeReadinessencapsulates a single probe attempt and returns a boolean to drive the loop.Macroscope summarized 22821ba.