fix: do not let a failed window creation surface as an uncaught exception (#2021)

`createWindow()` throws once its retries are exhausted. The call site in
`showMainWindow()` only attached a `then`, so that rejection became an unhandled
promise rejection and the user got a raw main-process error dialog instead of a
log line.

Attach a `catch` and log it.
This commit is contained in:
MOMO0302-02
2026-09-12 20:46:37 -07:00
committed by GitHub
parent 9ddc3ac479
commit 5e07e31ef5

View File

@@ -399,11 +399,14 @@ export function showMainWindow(): void {
return
}
void createWindow().then(() => {
clearQuitTimeout()
mainWindow?.show()
mainWindow?.focusOnWebView()
})
// createWindow 重试耗尽后会 throw缺 catch 会变成主进程未捕获异常弹窗。
void createWindow()
.then(() => {
clearQuitTimeout()
mainWindow?.show()
mainWindow?.focusOnWebView()
})
.catch((error) => mainWindowLogger.error('Failed to show main window', error))
}
export function closeMainWindow(): void {