From d6393c6718bd54ef2e639bdbcf9296918ef77ff1 Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Sat, 14 Feb 2026 01:31:33 +0800 Subject: [PATCH] fix(gateway): remove cleanupPendingRequests that rejects all concurrent users cleanupPendingRequests() iterated the service-wide pendingRequests Map and rejected every entry. Since it was called from connectUser's catch block (a per-user error path), one user's connection failure would spuriously reject other users' in-flight verify RPCs. The call was also redundant: sendVerifyRpc already cleans up its own entry in all failure paths (timeout, RPC error, route failure). Co-Authored-By: Claude Opus 4.6 --- apps/gateway/telegram/telegram.service.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/apps/gateway/telegram/telegram.service.ts b/apps/gateway/telegram/telegram.service.ts index 1b606c74..61147259 100644 --- a/apps/gateway/telegram/telegram.service.ts +++ b/apps/gateway/telegram/telegram.service.ts @@ -859,7 +859,6 @@ export class TelegramService implements OnModuleInit, OnModuleDestroy { } catch (error) { // Cleanup virtual device on failure this.eventsGateway.unregisterVirtualDevice(deviceId); - this.cleanupPendingRequests(); const message = error instanceof Error ? error.message : String(error); if (message.includes("REJECTED")) { @@ -1072,14 +1071,4 @@ export class TelegramService implements OnModuleInit, OnModuleDestroy { }); } - // ── Cleanup ── - - /** Cleanup all pending requests (used on verify failure) */ - private cleanupPendingRequests(): void { - for (const [id, pending] of this.pendingRequests) { - clearTimeout(pending.timer); - pending.reject(new Error("Cleaned up")); - this.pendingRequests.delete(id); - } - } }