From de7d459f6fa0d70523b345f6fa0f97012fe85852 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 5 Dec 2025 09:20:36 -0300 Subject: [PATCH] only transform filters with enableReconnect() when we're actually reconnecting. --- abstract-relay.ts | 21 +++++++++++++-------- jsr.json | 2 +- package.json | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/abstract-relay.ts b/abstract-relay.ts index 488820d..23eef04 100644 --- a/abstract-relay.ts +++ b/abstract-relay.ts @@ -159,12 +159,14 @@ export class AbstractRelay { } clearTimeout(this.connectionTimeoutHandle) this._connected = true + + const isReconnection = this.reconnectAttempts > 0 this.reconnectAttempts = 0 // resubscribe to all open subscriptions for (const sub of this.openSubs.values()) { sub.eosed = false - if (typeof this.enableReconnect === 'function') { + if (isReconnection && typeof this.enableReconnect === 'function') { sub.filters = this.enableReconnect(sub.filters) } sub.fire() @@ -206,14 +208,17 @@ export class AbstractRelay { private async waitForDummyReq() { return new Promise((resolve, _) => { // make a dummy request with expected empty eose reply - // ["REQ", "_", {"ids":["aaaa...aaaa"]}] - const sub = this.subscribe([{ ids: ['a'.repeat(64)] }], { - oneose: () => { - sub.close() - resolve(true) + // ["REQ", "_", {"ids":["aaaa...aaaa"], "limit": 0}] + const sub = this.subscribe( + [{ ids: ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], limit: 0 }], + { + oneose: () => { + sub.close() + resolve(true) + }, + eoseTimeout: this.pingTimeout + 1000, }, - eoseTimeout: this.pingTimeout + 1000, - }) + ) }) } diff --git a/jsr.json b/jsr.json index 7b90ddb..48f5050 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@nostr/tools", - "version": "2.18.2", + "version": "2.19.0", "exports": { ".": "./index.ts", "./core": "./core.ts", diff --git a/package.json b/package.json index 2ee2f54..ddc1bbe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "nostr-tools", - "version": "2.18.2", + "version": "2.19.0", "description": "Tools for making a Nostr client.", "repository": { "type": "git",