fix(desktop): prevent WSL startup timeout on Windows #6321
main fromrefs/pull/6321/head·opened View on GitHubFixes #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_modules through 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#
- Built the desktop app on Windows.
- Launched the server through
wsl.exe. - Confirmed the WSL backend became ready and the main window opened.
- Confirmed there were no missing-package or WSL packaging errors.
vp test run apps/server/vite.config.test.tsvp checkvp run typecheck
Checklist#
- This PR is small and focused
- I explained what changed and why
- No UI changes
Note
Low Risk Observability and comment-only edits; no changes to readiness timeouts, spawn logic, or packaging behavior in this diff.
Overview Adds startup timing instrumentation so slow WSL backend launches can be tied to spawn, migrations, HTTP listen, or readiness instead of only hitting the 60s timeout.
Desktop (DesktopBackendManager) records elapsedMs from run start and logs info when the backend process spawns (pid, port, paths, bootstrap delivery) and when readiness succeeds; readiness failures gain httpBaseUrl and the same elapsed time.
Server logs when the HTTP server is listening (formatted address, port, processUptimeMs). Migrations annotate schema-current / migration-success logs with processUptimeMs.
WSL config comments in DesktopBackendConfiguration are clarified (shared SQLite via Windows mount, asarUnpack wording for unpacked server bundle and external runtime deps); behavior is unchanged in this diff.
Note
Add startup timing logs to prevent WSL startup timeout on Windows#
Adds structured info logs at key startup milestones to help diagnose and prevent WSL startup timeouts on Windows.
DesktopBackendManagerlogs backend spawn and readiness events with timing (elapsedMs), pid, port, and config details.server.tslogs when the HTTP server starts listening, including address, port, and process uptime.Migrations.tsannotates migration run logs with process uptime in milliseconds.
Summary by CodeRabbit#
Enhancements
- Improved server and desktop backend startup logging with process details, readiness status, and elapsed times.
- Improved migration completion logs with process uptime.
- Updated server packaging to bundle runtime dependencies while preserving support for native and asset-based packages.
Tests
- Added coverage for dependency bundling and externalization scenarios.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/desktop/src/backend/DesktopBackendManager.ts line 893OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -886,3 +890,4 @@886890 );887891 });888892893+ const runStartedAt = yield* Clock.currentTimeMillis;
🟡 Medium
backend/DesktopBackendManager.ts:893elapsedMscomputes startup duration from twoClock.currentTimeMilliswall-clock readings. When the system clock is adjusted (NTP/manual correction) during startup, the loggedelapsedMscan be negative or otherwise incorrect. Consider usingClock.currentTimeMillisreplaced with a monotonic clock source such asperformance.now()or a monotonic time accessor for elapsed-time measurements.No longer relevant as of b8f1846540031c5e6840ae3edf85c3bde0facf4f
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-reviewagent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.Approvability#
Verdict: Approved b8f1846
This PR adds logging and timing instrumentation to help diagnose WSL startup timeouts. All changes are observability additions (elapsed time, process uptime, spawn/readiness logs) with no runtime behavior impact beyond logging output.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).@coderabbitai review
✅ Action performed
Review finished.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
🧹 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📥 Commits
Reviewing files that changed from the base of the PR and between e321667b100a18d5306f845c655dce6f20525776 and bc7f7f17549a24c668264f5db212869af7b24c31.
📒 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
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Read the four files on
pr-6321against today's main.The body says this bundles JavaScript dependencies so WSL loads a few files instead of walking
node_moduleson/mnt/c, and that is what beats the 60s readiness timeout. That change is not in the diff.What landed:
- comment wording in
DesktopBackendConfiguration(/mnt/c→ "Windows filesystem mount") elapsedMs/processUptimeMslogs on spawn, ready, readiness-failure, migrations, and HTTP listen
Those logs are useful. They do not prevent a timeout. CONFLICTING, and already approved — worth a second look at whether the bundle commit was dropped in a rebase.
I did not time a packaged WSL launch; there is nothing in these four files to time against.
- comment wording in
Yeah because the fix has already landed in main and neither of us noticed apparently. PR closed, although there's still issues in main - but they need to be addressed in a different PR
chrismin13(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
The 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.
Changes#
Runtime packaging
apps/server/vite.config.ts,apps/server/vite.config.test.ts,apps/desktop/src/backend/DesktopBackendConfiguration.ts,apps/desktop/src/wsl/DesktopWslEnvironment.tsStartup observability
apps/desktop/src/backend/DesktopBackendManager.tsonReady.apps/server/src/persistence/Migrations.ts,apps/server/src/server.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Suggested reviewers:
juliusmarminge🚥 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.
❤️ Share