From ef82c3d48b5cc8d67cda3a4c4bd2c7a8645c18c5 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sun, 2 Nov 2025 16:48:05 +0800 Subject: [PATCH 1/2] fix(electron): port-in-use dialog shown when opening a new window | --- apps/server/src/www.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/server/src/www.ts b/apps/server/src/www.ts index 7f3445312..4149d518b 100644 --- a/apps/server/src/www.ts +++ b/apps/server/src/www.ts @@ -158,14 +158,13 @@ function startHttpServer(app: Express) { // Not all situations require showing an error dialog. When Trilium is already open, // clicking the shortcut, the software icon, or the taskbar icon, or when creating a new window, // should simply focus on the existing window or open a new one, without displaying an error message. - if ("code" in error && error.code == "EADDRINUSE") { - if (process.argv.includes("--new-window") || !app.requestSingleInstanceLock()) { - console.error(message); - process.exit(1); - } + if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) { + console.error(message); + process.exit(1); + } else { + dialog.showErrorBox("Error while initializing the server", message); + process.exit(1); } - dialog.showErrorBox("Error while initializing the server", message); - process.exit(1); }); } else { console.error(message); From f3f07cdd28f2fdb5e8b2e734d6dffe57389d41e1 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sun, 2 Nov 2025 20:30:01 +0800 Subject: [PATCH 2/2] fix(electron): port-in-use dialog shown when opening a new window --- apps/server/src/www.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/server/src/www.ts b/apps/server/src/www.ts index 4149d518b..130d3a380 100644 --- a/apps/server/src/www.ts +++ b/apps/server/src/www.ts @@ -160,11 +160,10 @@ function startHttpServer(app: Express) { // should simply focus on the existing window or open a new one, without displaying an error message. if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) { console.error(message); - process.exit(1); } else { dialog.showErrorBox("Error while initializing the server", message); - process.exit(1); } + process.exit(1); }); } else { console.error(message);