fix(typedsocket): reject pending requests on disconnect to avoid hanging promises

This commit is contained in:
2026-02-26 16:58:33 +00:00
parent 1e53ee5b1a
commit 22ed5ebe59
3 changed files with 14 additions and 1 deletions

View File

@@ -325,6 +325,12 @@ export class TypedSocket {
this.updateStatus('disconnected');
// Reject all pending requests — the connection is gone and they'll never receive a response
for (const [id, pending] of this.pendingRequests) {
pending.reject(new Error('TypedSocket disconnected'));
}
this.pendingRequests.clear();
if (this.clientOptions?.autoReconnect && this.retryCount < this.clientOptions.maxRetries) {
this.scheduleReconnect();
}