From 6b475fbd01660a6adb8458a395d25a6278b8a862 Mon Sep 17 00:00:00 2001 From: ababak Date: Fri, 3 Apr 2026 17:18:24 +0300 Subject: [PATCH 1/3] Clear pending updates on socket close and process them on reconnect. Add `syncCommandId` method to align subscriptions with existing commands. --- .../app/core/ws/telemetry-websocket.service.ts | 15 +++++++++++++++ ui-ngx/src/app/core/ws/websocket.service.ts | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts index ddf5018a69..2d7c8af529 100644 --- a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts +++ b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts @@ -50,6 +50,7 @@ import { UnreadCountSubCmd, UnreadSubCmd, UnsubscribeCmd, + WebsocketCmd, WebsocketDataMsg } from '@app/shared/models/telemetry/telemetry.models'; import { Store } from '@ngrx/store'; @@ -94,11 +95,14 @@ export class TelemetryWebsocketService extends WebsocketService { if (subscriptionCommand.cmdId && (subscriptionCommand instanceof EntityDataCmd || subscriptionCommand instanceof UnreadSubCmd)) { + this.syncCommandId(subscriptionCommand, subscriber); this.cmdWrapper.cmds.push(subscriptionCommand); } } ); this.publishCommands(); + } else { + this.pendingUpdates.add(subscriber); } } @@ -177,4 +181,15 @@ export class TelemetryWebsocketService extends WebsocketService implements WsServ subscribersMap = new Map(); reconnectSubscribers = new Set(); + pendingUpdates = new Set(); wsUri: string; @@ -140,6 +141,7 @@ export abstract class WebsocketService implements WsServ if (close) { this.reconnectAttempts = 0; this.lastShownCloseCode = null; + this.pendingUpdates.clear(); this.closeSocket(); } } @@ -223,6 +225,7 @@ export abstract class WebsocketService implements WsServ } ); this.reconnectSubscribers.clear(); + this.processPendingUpdates(); } else { this.publishCommands(); } @@ -298,4 +301,13 @@ export abstract class WebsocketService implements WsServ message, type: notificationType })); } + + private processPendingUpdates() { + if (this.pendingUpdates.size > 0) { + this.pendingUpdates.forEach((subscriber) => { + this.update(subscriber); + }); + this.pendingUpdates.clear(); + } + } } From 3bd5d424e72f707edd3e3863ea679c97ba4ea822 Mon Sep 17 00:00:00 2001 From: ababak Date: Tue, 7 Apr 2026 17:45:48 +0300 Subject: [PATCH 2/3] fix: add subscriberCmdIds reverse index and defensive guard in processPendingUpdates --- .../core/ws/telemetry-websocket.service.ts | 21 ++++++++++++++----- ui-ngx/src/app/core/ws/websocket.service.ts | 11 +++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts index 2d7c8af529..fbe69d55ae 100644 --- a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts +++ b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts @@ -81,6 +81,12 @@ export class TelemetryWebsocketService extends WebsocketService(); + this.subscriberCmdIds.set(subscriber, cmdIds); + } + cmdIds.add(cmdId); } subscriptionCommand.cmdId = cmdId; this.cmdWrapper.cmds.push(subscriptionCommand); @@ -141,6 +147,13 @@ export class TelemetryWebsocketService extends WebsocketService implements WsServ lastCmdId = 0; subscribersCount = 0; subscribersMap = new Map(); + subscriberCmdIds = new Map>(); reconnectSubscribers = new Set(); pendingUpdates = new Set(); @@ -136,6 +137,7 @@ export abstract class WebsocketService implements WsServ } this.lastCmdId = 0; this.subscribersMap.clear(); + this.subscriberCmdIds.clear(); this.subscribersCount = 0; this.cmdWrapper.clear(); if (close) { @@ -304,10 +306,13 @@ export abstract class WebsocketService implements WsServ private processPendingUpdates() { if (this.pendingUpdates.size > 0) { - this.pendingUpdates.forEach((subscriber) => { - this.update(subscriber); - }); + const subscribers = Array.from(this.pendingUpdates); this.pendingUpdates.clear(); + for (const subscriber of subscribers) { + if (this.subscriberCmdIds.has(subscriber)) { + this.update(subscriber); + } + } } } } From da340fa5549197e32b4ea9395d2a3dfafe725d58 Mon Sep 17 00:00:00 2001 From: ababak Date: Wed, 8 Apr 2026 11:28:38 +0300 Subject: [PATCH 3/3] fix: check cmdId ownership instead of existence in syncCommandId --- ui-ngx/src/app/core/ws/telemetry-websocket.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts index fbe69d55ae..bc63938775 100644 --- a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts +++ b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts @@ -195,7 +195,7 @@ export class TelemetryWebsocketService extends WebsocketService