Skip to content

Commit 58ba99e

Browse files
authored
fix(desktop): avoid destroyed window permission checks (anomalyco#34300)
1 parent 6ee817d commit 58ba99e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/desktop/src/main/windows.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,18 @@ function addDocumentPolicy(response: Response, file: string) {
354354
}
355355

356356
function allowRendererPermissions(win: BrowserWindow) {
357+
const webContentsId = win.webContents.id
358+
357359
win.webContents.session.setPermissionRequestHandler((webContents, permission, callback, details) => {
358360
callback(
359361
rendererPermissions.has(permission) &&
360362
isTrustedRendererUrl(details.requestingUrl) &&
361-
webContents.id === win.webContents.id,
363+
webContents.id === webContentsId,
362364
)
363365
})
364366
win.webContents.session.setPermissionCheckHandler((webContents, permission, requestingOrigin, details) => {
365367
if (!rendererPermissions.has(permission)) return false
366-
if (webContents && webContents.id !== win.webContents.id) return false
368+
if (webContents && webContents.id !== webContentsId) return false
367369
return isTrustedRendererUrl(details.requestingUrl) || isTrustedRendererUrl(requestingOrigin)
368370
})
369371
}

0 commit comments

Comments
 (0)