eventsource: prevent resetting event id counter

This commit is contained in:
Hunter Miller 2022-06-21 14:04:30 -05:00
parent 421eef1d19
commit e5b66e3484
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@urbit/http-api", "name": "@urbit/http-api",
"version": "2.1.0", "version": "2.1.1",
"license": "MIT", "license": "MIT",
"description": "Library to interact with an Urbit ship over HTTP", "description": "Library to interact with an Urbit ship over HTTP",
"repository": { "repository": {

View File

@ -235,9 +235,9 @@ export class Urbit {
console.log('Received SSE: ', event); console.log('Received SSE: ', event);
} }
if (!event.id) return; if (!event.id) return;
this.lastEventId = parseInt(event.id, 10); const eventId = parseInt(event.id, 10);
if (this.lastEventId - this.lastAcknowledgedEventId > 20) { if (eventId - this.lastAcknowledgedEventId > 20) {
this.ack(this.lastEventId); this.ack(eventId);
} }
if (event.data && JSON.parse(event.data)) { if (event.data && JSON.parse(event.data)) {
@ -312,7 +312,7 @@ export class Urbit {
* *
*/ */
reset() { reset() {
if(this.verbose) { if (this.verbose) {
console.log('resetting'); console.log('resetting');
} }
this.delete(); this.delete();