fix(desktop): add timeout guards to prevent Windows startup hang#19281
Open
pengzha0 wants to merge 1 commit intoanomalyco:devfrom
Open
fix(desktop): add timeout guards to prevent Windows startup hang#19281pengzha0 wants to merge 1 commit intoanomalyco:devfrom
pengzha0 wants to merge 1 commit intoanomalyco:devfrom
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
Contributor
|
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. |
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 |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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