Ignore more ERR_FAILED instances
This commit is contained in:
parent
0e655ceeed
commit
85adb39d31
1 changed files with 14 additions and 1 deletions
15
app/main.ts
15
app/main.ts
|
@ -670,10 +670,20 @@ async function getTitleBarOverlay(): Promise<TitleBarOverlayOptions | false> {
|
|||
}
|
||||
|
||||
async function safeLoadURL(window: BrowserWindow, url: string): Promise<void> {
|
||||
let wasDestroyed = false;
|
||||
const onDestroyed = () => {
|
||||
wasDestroyed = true;
|
||||
};
|
||||
|
||||
window.webContents.on('did-stop-loading', onDestroyed);
|
||||
window.webContents.on('destroyed', onDestroyed);
|
||||
try {
|
||||
await window.loadURL(url);
|
||||
} catch (error) {
|
||||
if (windowState.readyForShutdown() && error?.code === 'ERR_FAILED') {
|
||||
if (
|
||||
(wasDestroyed || windowState.readyForShutdown()) &&
|
||||
error?.code === 'ERR_FAILED'
|
||||
) {
|
||||
getLogger().warn(
|
||||
'safeLoadURL: ignoring ERR_FAILED because we are shutting down',
|
||||
error
|
||||
|
@ -681,6 +691,9 @@ async function safeLoadURL(window: BrowserWindow, url: string): Promise<void> {
|
|||
return;
|
||||
}
|
||||
throw error;
|
||||
} finally {
|
||||
window.webContents.removeListener('did-stop-loading', onDestroyed);
|
||||
window.webContents.removeListener('destroyed', onDestroyed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue