From 50b92626053410d4cd07c1e5e8fbc6e3e4e99290 Mon Sep 17 00:00:00 2001 From: Thaddeus Date: Fri, 16 Aug 2024 14:24:37 +0200 Subject: [PATCH] fix: fix issue with connection id in debug logs --- src/realtimefeeds/realtimefeed.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/realtimefeeds/realtimefeed.ts b/src/realtimefeeds/realtimefeed.ts index c020288..6c0d8b7 100644 --- a/src/realtimefeeds/realtimefeed.ts +++ b/src/realtimefeeds/realtimefeed.ts @@ -31,7 +31,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable { private readonly _filters: Filter[] private _receivedMessagesCount = 0 private _ws?: WebSocket - private _connectionId = connectionCounter++ + private _connectionId = -1 private _wsClientOptions: WebSocket.ClientOptions | ClientRequestArgs protected readonly originHeader: string | undefined = undefined @@ -73,6 +73,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable { while (true) { try { + this._connectionId = connectionCounter++ const subscribeMessages = this.mapToSubscribeMessages(this._filters) const finalWssUrl = await this.getWebSocketUrl() @@ -294,7 +295,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable { } } - this.debug('(connection id: %d) estabilished connection', this._connectionId) + this.debug('(connection id: %d) established connection', this._connectionId) //wait before fetching snapshots until we're sure we've got proper connection estabilished (received some messages) while (this._receivedMessagesCount < symbolsCount * 2) {