From e807c3959add0d394c679d19d5f6dd0ab340645f Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Tue, 19 Sep 2023 17:53:21 +0200 Subject: [PATCH] fix #157: catch EADDRINUSE to prevent endless restarts if the port is already in use --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index ddd02ed..ae50931 100644 --- a/index.js +++ b/index.js @@ -124,6 +124,14 @@ if (process.argv.includes('--localhost-only')) { server.listen(port); } +server.on('error', (err) => { + if (err.code === 'EADDRINUSE') { + console.error(err); + console.info("Error EADDRINUSE received, exiting process without restarting process..."); + process.exit(0) + } +}); + class PairDropServer { constructor() {