fix(window): guard close handler against destroyed BrowserWindow#1783
Merged
fix(window): guard close handler against destroyed BrowserWindow#1783
Conversation
When close-to-tray is enabled, the close event handler calls mainWindow.hide(). If the BrowserWindow has already been destroyed (e.g. via windowControlsBridge.close()), this throws "TypeError: Object has been destroyed". Add an isDestroyed() check at the top of the close handler to bail out early when the window is no longer valid. Fixes ELECTRON-ET
Contributor
Code Review:fix(window): guard close handler against destroyed BrowserWindow (#1783)变更概述本 PR 在 方案评估结论:✅ 方案合理
问题清单🔵 LOW —
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🔵 LOW | tests/unit/mainWindowCloseHandler.test.ts:17 |
simulateCloseHandler 应移至外层作用域(lint 警告) |
结论
✅ 批准合并 — 无阻塞性问题
修复正确且极为克制,测试覆盖了关键场景。唯一的 LOW 问题是测试文件中的 lint 风格警告,不阻塞合并。
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
Contributor
|
✅ 已自动 review,无阻塞性问题,正在触发自动合并。 |
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
isDestroyed()guard in main window close event handler to preventTypeError: Object has been destroyedwhen close-to-tray is enabledChanges
mainWindow.isDestroyed()is true in thecloseevent handlerRelated Issue
Closes #1782
Sentry
TypeError: Object has been destroyedatsrc/index.ts:345(mainWindow.hide())windowControlsBridge.close()triggers thecloseevent, but the BrowserWindow may already be destroyed by the time the handler callshide()Verification
tsc --noEmit)Test Plan