fix(desktop): prevent WSL startup timeout on Windows - #6321
Conversation
📝 WalkthroughWalkthroughThe PR updates CLI runtime dependency bundling and related WSL packaging documentation. It also adds elapsed-time and process details to desktop backend, migration, and HTTP server startup logs. ChangesRuntime packaging
Startup observability
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Pull request overview
Fixes Windows packaged desktop app startup timeouts when using the WSL backend by reducing slow /mnt/c-mounted filesystem dependency resolution during server bootstrap, and by adding more granular startup timing logs to make future regressions diagnosable.
Changes:
- Update server CLI bundling policy to bundle direct runtime JS dependencies by default, while keeping native/asset-owning/runtime-specific packages external.
- Add unit coverage for the new bundling policy in
apps/server/vite.config.test.ts. - Add startup timing logs for backend spawn/readiness (desktop) and for HTTP listen + migrations (server).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apps/server/vite.config.ts | Changes CLI bundling policy: bundle direct runtime deps by default, with an explicit external allowlist. |
| apps/server/vite.config.test.ts | Adds focused tests validating bundling vs externalization behavior. |
| apps/server/src/server.ts | Logs HTTP listen timing details (incl. process uptime) during startup. |
| apps/server/src/persistence/Migrations.ts | Annotates migration logs with process uptime timing. |
| apps/desktop/src/wsl/DesktopWslEnvironment.ts | Updates probe comments to reflect the new “mostly bundled” server dependency model. |
| apps/desktop/src/backend/DesktopBackendManager.ts | Adds elapsed-time logging for backend spawn, readiness success, and readiness failure. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. The PR inverts the bundling defaults in vite.config.ts, changing from explicit inclusion to default bundling with exceptions. This build configuration change could affect runtime behavior if native or asset-resolving packages are incorrectly bundled, warranting human verification that the exclusion list is complete. You can customize Macroscope's approvability policy. Learn more. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/server/vite.config.test.ts (1)
17-21: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCover every explicit external package.
apps/server/vite.config.tsLines 21-32 define five external packages, but this test covers onlynode-ptyand@anthropic-ai/claude-agent-sdk. Add assertions for@effect/platform-bun,@effect/sql-sqlite-bun, and@ff-labs/fff-node. These packages are Bun-only or native and can break packaged WSL startup if bundling changes.As per coding guidelines, backend behavior changes in
apps/server/**/*.test.{ts,tsx}must include focused tests for that behavior.Add the missing assertions
it("keeps packages that need runtime files external", () => { assert.isFalse(shouldBundleCliDependency("node-pty")); assert.isFalse(shouldBundleCliDependency("`@anthropic-ai/claude-agent-sdk/cli.js`")); assert.isFalse(shouldBundleCliDependency("node-pty/lib/index.js")); + assert.isFalse(shouldBundleCliDependency("`@effect/platform-bun`")); + assert.isFalse(shouldBundleCliDependency("`@effect/sql-sqlite-bun`")); + assert.isFalse(shouldBundleCliDependency("`@ff-labs/fff-node`")); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/server/vite.config.test.ts` around lines 17 - 21, Add focused assertions in the “keeps packages that need runtime files external” test to verify shouldBundleCliDependency returns false for `@effect/platform-bun`, `@effect/sql-sqlite-bun`, and `@ff-labs/fff-node`, covering every package explicitly configured as external in vite.config.ts.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/server/vite.config.test.ts`:
- Around line 17-21: Add focused assertions in the “keeps packages that need
runtime files external” test to verify shouldBundleCliDependency returns false
for `@effect/platform-bun`, `@effect/sql-sqlite-bun`, and `@ff-labs/fff-node`,
covering every package explicitly configured as external in vite.config.ts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3455d711-a738-4c63-b0bf-40dcad224909
📒 Files selected for processing (7)
apps/desktop/src/backend/DesktopBackendConfiguration.tsapps/desktop/src/backend/DesktopBackendManager.tsapps/desktop/src/wsl/DesktopWslEnvironment.tsapps/server/src/persistence/Migrations.tsapps/server/src/server.tsapps/server/vite.config.test.tsapps/server/vite.config.ts
Fixes #4535.
Related to #5522 and #5876. This PR reduces slow module loading, but it does not change readiness retry behavior or reduce the number of files unpacked by the installer.
What Changed
Fixes the packaged Windows app failing to launch when using the WSL backend.
The server runs inside WSL, but its files are installed on the Windows filesystem. WSL accesses those files through a mount such as
/mnt/c, which is much slower than the Linux filesystem.Before this change, the server loaded a large number of JavaScript files from
node_modulesthrough that mount. Startup could take longer than the desktop app’s 60-second readiness timeout. The desktop app then treated the WSL backend as failed, leaving the app stuck or unable to open.This change bundles normal JavaScript dependencies into the server output. WSL now loads a few bundle files instead of resolving a large dependency tree through the Windows filesystem.
Packages that need native binaries or other files at runtime remain external.
Startup timing was also added to the logs. If startup becomes slow again, the logs will show whether the delay happened while starting the process, running database migrations, opening the HTTP server, or waiting for readiness.
Why
Without this change, the packaged app could be unusable with the WSL backend because the backend did not become ready before the timeout.
Increasing the timeout would only hide the problem and make failures take longer. Reducing filesystem work makes startup faster and more reliable.
Testing
wsl.exe.vp test run apps/server/vite.config.test.tsvp checkvp run typecheckChecklist
Note
Medium Risk
Changes server packaging/bundling behavior for the packaged desktop CLI, which can break WSL or native-dep loading if the external allowlist is wrong. Timing logs are low risk.
Overview
Fixes packaged Windows + WSL backend startups timing out by bundling normal JS runtime deps into the server CLI, so WSL loads a few chunks instead of walking a large
node_modulestree through the slow Windows filesystem mount.shouldBundleCliDependencynow bundles declared runtime dependencies by default, while keeping native/asset-owning packages external (node-pty, Bun-only packages, Claude agent SDK, etc.). Adds coverage for that bundling policy.Also adds startup timing logs so slow boots are easier to diagnose: spawn/readiness
elapsedMsin the desktop backend manager, plusprocessUptimeMson migration completion and HTTP listen.Reviewed by Cursor Bugbot for commit d3e17f4. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix WSL startup timeout by improving CLI bundling and adding startup timing logs
shouldBundleCliDependencyin vite.config.ts to bundle all declared runtime dependencies by default, while keeping native/runtime-sensitive packages (e.g.node-pty,@effect/sql-sqlite-bun) external via a newexternalRuntimePackageNamesset.processUptimeMsin server.ts, backend process spawn/readiness events withelapsedMsin DesktopBackendManager.ts, and migration timing in Migrations.ts.shouldBundleCliDependencyin vite.config.test.ts.externalRuntimePackageNames; previously only packages matchingbundledPackagePrefixeswere bundled.Macroscope summarized d3e17f4.
Summary by CodeRabbit
Enhancements
Tests