From b1b9bc01e809340df6793af57cf380c86ccb111e Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 30 Jun 2021 13:23:20 +1000 Subject: [PATCH] @urbit/http-api: fix ack debouncing --- pkg/npm/http-api/src/Urbit.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/npm/http-api/src/Urbit.ts b/pkg/npm/http-api/src/Urbit.ts index a43b8eb2e1..4a6da547f5 100644 --- a/pkg/npm/http-api/src/Urbit.ts +++ b/pkg/npm/http-api/src/Urbit.ts @@ -269,6 +269,12 @@ export class Urbit { this.abort.abort(); this.abort = new AbortController(); this.uid = `${Math.floor(Date.now() / 1000)}-${hexString(6)}`; + if(this.debounceTimer) { + clearTimeout(this.debounceTimer); + this.debounceTimer = null; + } + this.calm = true; + this.outstandingJSON = []; this.lastEventId = 0; this.lastAcknowledgedEventId = 0; this.outstandingSubscriptions = new Map(); @@ -321,7 +327,7 @@ export class Urbit { private outstandingJSON: Message[] = []; - private debounceTimer: any = null; + private debounceTimer: NodeJS.Timeout = null; private debounceInterval = 500; private calm = true; @@ -350,6 +356,7 @@ export class Urbit { body }); } catch (error) { + console.log(error); json.forEach(failed => this.outstandingJSON.push(failed)); if (this.onError) { this.onError(error);