From cf0450f29849e2702d6150cba1be36a487db6550 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Thu, 21 Mar 2024 13:04:31 +0800 Subject: [PATCH] :bug: Fix(custom): fix error handling in server startup --- src/main/server/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/server/index.ts b/src/main/server/index.ts index 2eff0b98..6de18394 100644 --- a/src/main/server/index.ts +++ b/src/main/server/index.ts @@ -164,10 +164,11 @@ class Server { port = parseInt(port, 10) } this.httpServer.listen(port, this.config.host).on('error', async (err: ErrnoException) => { - if (err.errno === 'EADDRINUSE') { + if (err.code === 'EADDRINUSE') { try { // make sure the system has a PicGo Server instance await axios.post(ensureHTTPLink(`${this.config.host}:${port}/heartbeat`)) + logger.info(`[PicList Server] server is already running at ${port}`) this.shutdown(true) } catch (e) { logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)