From 123107f3de57fa4df495354347e59257cedf8bef Mon Sep 17 00:00:00 2001 From: Matthew McAllister Date: Fri, 6 Oct 2023 17:27:32 -0400 Subject: [PATCH] review fix to simplify change --- src/transports/websocket.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/transports/websocket.ts b/src/transports/websocket.ts index 869c10dd..c70c3a58 100644 --- a/src/transports/websocket.ts +++ b/src/transports/websocket.ts @@ -327,11 +327,19 @@ export class WebSocketTransport< // Check if we should close the current connection if (!connectionClosed && (urlChanged || connectionUnresponsive)) { - const reason = urlChanged - ? `Websocket url has changed from ${this.currentUrl} to ${urlFromConfig}, closing connection...` - : `Last message was received ${timeSinceLastMessage} ago, exceeding the threshold of ${context.adapterSettings.WS_SUBSCRIPTION_UNRESPONSIVE_TTL}ms, closing connection...` - const logfn = urlChanged && this.isUrlSubscriptionWebsocket ? logger.debug : logger.info - censorLogs(() => logfn(reason)) + if (urlChanged) { + censorLogs(() => + logger.debug( + `Websocket url has changed from ${this.currentUrl} to ${urlFromConfig}, closing connection...`, + ), + ) + } else { + censorLogs(() => + logger.info( + `Last message was received ${timeSinceLastMessage} ago, exceeding the threshold of ${context.adapterSettings.WS_SUBSCRIPTION_UNRESPONSIVE_TTL}ms, closing connection...`, + ), + ) + } // Check if connection was opened very recently; if so, wait a bit before continuing. // This is so if we just opened the connection and are waiting to receive some messages, @@ -468,12 +476,3 @@ export class WebsocketReverseMappingTransport< return this.requestMapping.get(value) } } - -export class UrlSubscriptionWebsocketTransport< - T extends WebsocketTransportGenerics, -> extends WebSocketTransport { - constructor(config: WebSocketTransportConfig) { - super(config) - this.isUrlSubscriptionWebsocket = true - } -}