fix(startup): preserve Electron WebContents receivers
This commit is contained in:
+29
-19
@@ -148,8 +148,8 @@ function armScheduledStart(schedMs: number, opts: { startOnPast: boolean }): voi
|
||||
logger.info(`Geplanter Start gearmt: ${new Date(schedMs).toLocaleString()}`);
|
||||
}
|
||||
|
||||
function createWindow(): BrowserWindow {
|
||||
const window = new BrowserWindow({
|
||||
function createWindow(): BrowserWindow {
|
||||
const window = new BrowserWindow({
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
minWidth: 1120,
|
||||
@@ -160,6 +160,10 @@ function createWindow(): BrowserWindow {
|
||||
webPreferences: createMainWindowWebPreferences(path.join(__dirname, "../preload/preload.js"))
|
||||
});
|
||||
|
||||
window.webContents.on("did-fail-load", (_event, errorCode, errorDescription, validatedURL, isMainFrame) => {
|
||||
logger.error(`Renderer-Laden fehlgeschlagen: id=${window.id} code=${errorCode} mainFrame=${isMainFrame} url=${validatedURL} error=${errorDescription}`);
|
||||
});
|
||||
|
||||
applyMainWindowSecurity(window, {
|
||||
rendererUrl: getTrustedRendererUrl(),
|
||||
externalHosts: MAIN_WINDOW_EXTERNAL_HOSTS
|
||||
@@ -181,10 +185,14 @@ function createWindow(): BrowserWindow {
|
||||
window.setMenuBarVisibility(false);
|
||||
window.setAutoHideMenuBar(true);
|
||||
|
||||
if (isDevMode()) {
|
||||
void window.loadURL(DEV_SERVER_URL);
|
||||
} else {
|
||||
void window.loadFile(path.join(app.getAppPath(), "build", "renderer", "index.html"));
|
||||
if (isDevMode()) {
|
||||
void window.loadURL(DEV_SERVER_URL).catch((error) => {
|
||||
logger.error(`Renderer-Start fehlgeschlagen: ${String(error?.stack || error)}`);
|
||||
});
|
||||
} else {
|
||||
void window.loadFile(path.join(app.getAppPath(), "build", "renderer", "index.html")).catch((error) => {
|
||||
logger.error(`Renderer-Start fehlgeschlagen: ${String(error?.stack || error)}`);
|
||||
});
|
||||
}
|
||||
|
||||
return window;
|
||||
@@ -955,19 +963,21 @@ app.whenReady().then(() => {
|
||||
bindMainWindowLifecycle(mainWindow);
|
||||
}
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error("App startup failed:", error);
|
||||
app.quit();
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on("before-quit", () => {
|
||||
if (updateQuitTimer) { clearTimeout(updateQuitTimer); updateQuitTimer = null; }
|
||||
}).catch((error) => {
|
||||
logger.error(`App-Start fehlgeschlagen: ${String(error?.stack || error)}`);
|
||||
console.error("App startup failed:", error);
|
||||
app.quit();
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
logger.warn("Alle Hauptfenster geschlossen");
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on("before-quit", () => {
|
||||
if (updateQuitTimer) { clearTimeout(updateQuitTimer); updateQuitTimer = null; }
|
||||
stopClipboardWatcher();
|
||||
destroyTray();
|
||||
shutdownDaemon();
|
||||
|
||||
Reference in New Issue
Block a user