From e5b66e34847f93d495be31435b160d85a0b56e04 Mon Sep 17 00:00:00 2001 From: Hunter Miller Date: Tue, 21 Jun 2022 14:04:30 -0500 Subject: [PATCH] eventsource: prevent resetting event id counter --- pkg/npm/http-api/package.json | 2 +- pkg/npm/http-api/src/Urbit.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/npm/http-api/package.json b/pkg/npm/http-api/package.json index 8b5f49767..75bba5e5c 100644 --- a/pkg/npm/http-api/package.json +++ b/pkg/npm/http-api/package.json @@ -1,6 +1,6 @@ { "name": "@urbit/http-api", - "version": "2.1.0", + "version": "2.1.1", "license": "MIT", "description": "Library to interact with an Urbit ship over HTTP", "repository": { diff --git a/pkg/npm/http-api/src/Urbit.ts b/pkg/npm/http-api/src/Urbit.ts index ab473e6d3..aa59149d1 100644 --- a/pkg/npm/http-api/src/Urbit.ts +++ b/pkg/npm/http-api/src/Urbit.ts @@ -235,9 +235,9 @@ export class Urbit { console.log('Received SSE: ', event); } if (!event.id) return; - this.lastEventId = parseInt(event.id, 10); - if (this.lastEventId - this.lastAcknowledgedEventId > 20) { - this.ack(this.lastEventId); + const eventId = parseInt(event.id, 10); + if (eventId - this.lastAcknowledgedEventId > 20) { + this.ack(eventId); } if (event.data && JSON.parse(event.data)) { @@ -312,7 +312,7 @@ export class Urbit { * */ reset() { - if(this.verbose) { + if (this.verbose) { console.log('resetting'); } this.delete();