Skip to content

Commit 421c1f2

Browse files
authored
fix(electron): port-in-use dialog shown when opening a new window | (#7595)
2 parents 97e8774 + 5782e58 commit 421c1f2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

apps/server/src/www.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,11 @@ 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+
} else {
164+
dialog.showErrorBox("Error while initializing the server", message);
166165
}
167-
dialog.showErrorBox("Error while initializing the server", message);
168166
process.exit(1);
169167
});
170168
} else {

0 commit comments

Comments
 (0)