fix(desktop): guard destroyed recovery windows (#37406)

This commit is contained in:
Luke Parker
2026-07-17 11:22:18 +10:00
committed by GitHub
parent 08fb473735
commit 4436678f7d
4 changed files with 38 additions and 11 deletions
+29
View File
@@ -0,0 +1,29 @@
export const destroyedWindowURL = "<destroyed>"
type WebContentsURLState = {
isDestroyed(): boolean
getURL(): string
}
type WindowURLState = {
isDestroyed(): boolean
readonly webContents: WebContentsURLState
}
export function safeWebContentsURL(webContents: WebContentsURLState) {
try {
if (webContents.isDestroyed()) return destroyedWindowURL
return webContents.getURL()
} catch {
return destroyedWindowURL
}
}
export function safeWindowURL(win: WindowURLState) {
try {
if (win.isDestroyed()) return destroyedWindowURL
return safeWebContentsURL(win.webContents)
} catch {
return destroyedWindowURL
}
}