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 = () => {