fix(desktop): guard destroyed recovery windows#37406
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Desktop main-process recovery/diagnostics logging against Electron lifecycle races where a BrowserWindow/WebContents is already destroyed when event handlers fire, preventing uncaught TypeError: Object has been destroyed crashes and allowing recovery dialogs/export-logs flows to proceed.
Changes:
- Introduces
safeWindowURL/safeWebContentsURLhelpers that tolerate destroyed instances and exceptions when reading URLs. - Switches window recovery and unresponsive sampling logs to use the safe URL helpers.
- Hardens app-level
render-process-gonelogging similarly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/desktop/src/main/windows.ts | Uses safeWindowURL(win) in recovery/unresponsive/responsive/load-failure diagnostics to avoid destroyed-object URL access. |
| packages/desktop/src/main/window-state.ts | Adds safe URL access helpers that guard isDestroyed() and catch Electron “destroyed” exceptions. |
| packages/desktop/src/main/unresponsive.ts | Uses safeWindowURL(win) in the unresponsive sampler output to avoid lifecycle-race crashes while logging. |
| packages/desktop/src/main/index.ts | Uses safeWebContentsURL(webContents) in app-level render-process-gone logging to avoid destroyed WebContents URL access. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
avion23
pushed a commit
to avion23/opencode
that referenced
this pull request
Jul 17, 2026
This was referenced Jul 18, 2026
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.
Summary
Related to #33106, #32923, and #35501.
Testing
Test decision
No regression test is included because reproducing this requires Electron's native app.exit and responsive event ordering; structural fakes would not exercise the failing lifecycle race.