Skip to content

Commit ef82c3d

Browse files
committed
fix(electron): port-in-use dialog shown when opening a new window |
1 parent 3f0b0f9 commit ef82c3d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

apps/server/src/www.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,13 @@ function startHttpServer(app: Express) {
158158
// Not all situations require showing an error dialog. When Trilium is already open,
159159
// clicking the shortcut, the software icon, or the taskbar icon, or when creating a new window,
160160
// should simply focus on the existing window or open a new one, without displaying an error message.
161-
if ("code" in error && error.code == "EADDRINUSE") {
162-
if (process.argv.includes("--new-window") || !app.requestSingleInstanceLock()) {
163-
console.error(message);
164-
process.exit(1);
165-
}
161+
if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) {
162+
console.error(message);
163+
process.exit(1);
164+
} else {
165+
dialog.showErrorBox("Error while initializing the server", message);
166+
process.exit(1);
166167
}
167-
dialog.showErrorBox("Error while initializing the server", message);
168-
process.exit(1);
169168
});
170169
} else {
171170
console.error(message);

0 commit comments

Comments
 (0)