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 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang 2026-02-14 01:31:33 +08:00
parent 7af2a0d1b1
commit d6393c6718

View file

@ -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);
}
}
}