diff --git a/abstract-pool.ts b/abstract-pool.ts index 542abd4..85e6e69 100644 --- a/abstract-pool.ts +++ b/abstract-pool.ts @@ -50,6 +50,9 @@ export class AbstractSimplePool { verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent, websocketImplementation: this._WebSocket, }) + relay.onclose = () => { + this.relays.delete(url) + } if (params?.connectionTimeout) relay.connectionTimeout = params.connectionTimeout this.relays.set(url, relay) } @@ -61,6 +64,7 @@ export class AbstractSimplePool { close(relays: string[]) { relays.map(normalizeURL).forEach(url => { this.relays.get(url)?.close() + this.relays.delete(url) }) } diff --git a/abstract-relay.ts b/abstract-relay.ts index 631bfdb..bce8681 100644 --- a/abstract-relay.ts +++ b/abstract-relay.ts @@ -319,6 +319,7 @@ export class AbstractRelay { this.closeAllSubscriptions('relay connection closed by us') this._connected = false this.ws?.close() + this.onclose?.() } // this is the function assigned to this.ws.onmessage diff --git a/jsr.json b/jsr.json index e4b7307..8553aa2 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@nostr/tools", - "version": "2.15.0", + "version": "2.15.1", "exports": { ".": "./index.ts", "./core": "./core.ts",