fix(desktop): add timeout guards to prevent Windows startup hang#19281
fix(desktop): add timeout guards to prevent Windows startup hang#19281pengzha0 wants to merge 1 commit into
Conversation
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
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
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 |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #631
Type of change
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:
sqliteFileExists()checks~/.local/share/opencode/opencode.db— a Linux-only path that never exists on Windows. SoneedsMigrationis alwaystrueon Windows, and the app waits for asqlite-migration:doneevent from the sidecar.Both
sqliteDone?.promiseandloadingComplete.promiseare 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
needsMigrationisfalseand the whole code path is skipped.Fixes:
sqliteFileExists()now uses%APPDATA%\opencode\opencode.dbon WindowssqliteDonewait gets a 30s timeoutloadingCompletewait gets a 10s timeoutHow 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