Merge pull request #5864 from urbit/hm/http-api-sub-reuse

http-api: prevent reuse of old subscription ids
This commit is contained in:
Hunter Miller 2022-06-21 14:41:35 -05:00 committed by GitHub
commit 8304073cc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -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": {

View File

@ -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();