detect EADDRINUSE on server start (#1348)

* detect `EADDRINUSE` on server start

* @ts-expect-error

* send portError to electron

* use escalateErrorFn

* dont move in docker

* allow errors to be sendt to electron UI

* Log after the new port is found

* Update comment

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>

* update comment

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>

* update comment

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>

* rename to escalate

* extract `serverTryDesiredPort`

* type check server.address()

* request shutdown on `unrecoverable` `escalateError`

* combine network utils

* reject promise

* not unrecoverable by default

* unneeded assignment

---------

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
Alex Christoffer Rasmussen
2024-12-22 16:23:47 +01:00
committed by GitHub
parent 1af394cd49
commit 29243e3f6c
6 changed files with 121 additions and 54 deletions
+8 -3
View File
@@ -23,7 +23,7 @@ if (!isProduction) {
}
/** Flag holds server loading state */
let loaded = 'Ontime running';
let loaded = 'Ontime starting';
/**
* Flag whether user has requested a quit
@@ -109,8 +109,13 @@ function askToQuit() {
* Allows processes to escalate errors to be shown in electron
* @param {string} error
*/
function escalateError(error) {
dialog.showErrorBox('An unrecoverable error occurred', error);
function escalateError(error, unrecoverable = false) {
if (unrecoverable) {
dialog.showErrorBox('An unrecoverable error occurred', error);
appShutdown();
} else {
dialog.showErrorBox('An error occurred', error);
}
}
/**