Skip to content

fix(desktop): add timeout guards to prevent Windows startup hang#19281

Open
pengzha0 wants to merge 1 commit intoanomalyco:devfrom
pengzha0:fix/desktop-windows-startup-hang
Open

fix(desktop): add timeout guards to prevent Windows startup hang#19281
pengzha0 wants to merge 1 commit intoanomalyco:devfrom
pengzha0:fix/desktop-windows-startup-hang

Conversation

@pengzha0
Copy link
Copy Markdown

@pengzha0 pengzha0 commented Mar 26, 2026

Issue for this PR

Closes #631

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The Electron desktop app hangs forever on "Just a moment..." loading screen on Windows when the sidecar is slow to start (e.g. in offline/intranet environments).

Two issues cause this:

  1. sqliteFileExists() checks ~/.local/share/opencode/opencode.db — a Linux-only path that never exists on Windows. So needsMigration is always true on Windows, and the app waits for a sqlite-migration:done event from the sidecar.

  2. Both sqliteDone?.promise and loadingComplete.promise are awaited with no timeout. When the sidecar blocks on network requests (models.dev fetch, plugin installs) before emitting the migration event, the app hangs indefinitely.

This is masked on internet-connected Windows because the sidecar finishes network init fast enough to emit the event. On macOS/Linux the path check is correct so needsMigration is false and the whole code path is skipped.

Fixes:

  • sqliteFileExists() now uses %APPDATA%\opencode\opencode.db on Windows
  • sqliteDone wait gets a 30s timeout
  • loadingComplete wait gets a 10s timeout

How did you verify your code works?

Tested on Windows in an intranet environment (no internet access). Before the fix, the app hung permanently on loading screen. After the fix, the app starts within seconds.

Screenshots / recordings

N/A — not a UI change, fixes a startup hang.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

On Windows, sqliteFileExists() uses the Linux path ~/.local/share/ which
never exists, causing needsMigration to always be true. Combined with
no timeout on the sqliteDone and loadingComplete promise awaits, this
causes the app to hang indefinitely on the "Just a moment..." loading
screen when the sidecar is slow to initialize (e.g., due to network
requests in offline/intranet environments).

Fixes:
- Use platform-appropriate path in sqliteFileExists() for Windows
- Add 30s timeout to SQLite migration wait
- Add 10s timeout to loading window completion wait
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search results show PR #19281 itself and some related but different PRs:

Potential Related PRs (but not duplicates):

No duplicate PRs found

@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@pengzha0
Copy link
Copy Markdown
Author

The e2e (windows) failure is in session-model-persistence.spec.ts ("session model restore across workspaces"), which is unrelated to the changes in this PR. This PR only modifies packages/desktop-electron/src/main/index.ts. The test also has 2 other flaky tests, suggesting pre-existing instability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Support

1 participant