From 83cbd678f764954ca316c5c74e792163a66c2be3 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Tue, 1 Jun 2021 18:04:09 +0930 Subject: [PATCH] fix: dont reconnect on 401 --- app/mothership/custom-socket.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/mothership/custom-socket.ts b/app/mothership/custom-socket.ts index 8777df519..1207997eb 100644 --- a/app/mothership/custom-socket.ts +++ b/app/mothership/custom-socket.ts @@ -178,6 +178,7 @@ export class CustomSocket { protected onDisconnect() { // Connection attempts let connectionAttempts = this.connectionAttempts; + let shouldReconnect = true; const logger = this.logger; const connect = this.connect.bind(this); @@ -210,6 +211,7 @@ export class CustomSocket { // Unauthorized - Invalid/missing API key. 4401: async () => { this.logger.debug('Invalid API key, waiting for new key...'); + shouldReconnect = false; }, // Request Timeout - Mothership disconnected us. 4408: async () => { @@ -285,6 +287,11 @@ export class CustomSocket { logger.error('Connection closed with code=%s reason="%s"', code, (error as Error).message); } + // We shouldn't reconnect + if (!shouldReconnect) { + return; + } + try { // Wait a few seconds await sleep(backoff(connectionAttempts, ONE_MINUTE, 5));