mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Electron.WindowManager.BrowserWindows retains references to destroyed windows after Close() is called #1050
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @HarlanHugh on GitHub (Jan 15, 2026).
Description
When a BrowserWindow is closed via window.Close(), the window is destroyed on the Electron side, but the BrowserWindow object remains in the Electron.WindowManager.BrowserWindows collection. This causes errors when subsequently iterating or accessing windows in the collection.
Steps to Reproduce
Expected Behavior
Closed/destroyed windows should be automatically removed from Electron.WindowManager.BrowserWindows, or there should be a way to detect destroyed windows before accessing them.
Actual Behavior
The collection retains stale BrowserWindow references. Attempting to call methods on these destroyed windows results in:
Uncaught exception: TypeError: Object has been destroyed
at Socket. (....electron\api\browserWindows.js:259:27)
Suggested Fix
Subscribe to Electron's closed event and remove the window from BrowserWindows when it fires