From 711c22a9e56ed1b76e22ec6297ef65738ccd6a16 Mon Sep 17 00:00:00 2001 From: wisplite Date: Thu, 23 Apr 2026 09:43:08 -0500 Subject: [PATCH] clean up promises when client disconnects --- dist/index.js | 7 +++++++ src/index.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/dist/index.js b/dist/index.js index bd5313c..bf24948 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29,6 +29,13 @@ export class TetherClient { })); }); }; + this.websocketHandler.onClose = () => { + this.pendingMutations.forEach(pending => { + clearTimeout(pending.timeoutId); + pending.reject(new Error('Connection closed')); + }); + this.pendingMutations.clear(); + }; }; disconnect = () => { this.websocketHandler.close(); diff --git a/src/index.ts b/src/index.ts index e5a110a..15878d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,6 +36,13 @@ export class TetherClient { })); }); }; + this.websocketHandler.onClose = () => { + this.pendingMutations.forEach(pending => { + clearTimeout(pending.timeoutId); + pending.reject(new Error('Connection closed')); + }); + this.pendingMutations.clear(); + }; }; disconnect = () => {