diff --git a/abstract-pool.ts b/abstract-pool.ts index 90aa9c6..9a78570 100644 --- a/abstract-pool.ts +++ b/abstract-pool.ts @@ -16,8 +16,7 @@ import { Relay } from './relay.ts' export type SubCloser = { close: (reason?: string) => void } export type AbstractPoolConstructorOptions = AbstractRelayConstructorOptions & { - // automaticallyAuth takes a relay URL and should return null - // in case that relay shouldn't be authenticated against + // automaticallyAuth takes a relay URL and should return null in case that relay shouldn't be authenticated against // or a function to sign the AUTH event template otherwise (that function may still throw in case of failure) automaticallyAuth?: (relayURL: string) => null | ((event: EventTemplate) => Promise) // onRelayConnectionFailure is called with the URL of a relay that failed the initial connection @@ -269,10 +268,13 @@ export class AbstractSimplePool { filter: Filter, params: Pick, ): SubCloser { - const subcloser = this.subscribe(relays, filter, { + let subcloser: SubCloser + subcloser = this.subscribe(relays, filter, { ...params, oneose() { - subcloser.close('closed automatically on eose') + const reason = 'closed automatically on eose' + if (subcloser) subcloser.close(reason) + else params.onclose?.(relays.map(_ => reason)) }, }) return subcloser diff --git a/jsr.json b/jsr.json index 23010cb..edd6dcb 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@nostr/tools", - "version": "2.23.0", + "version": "2.23.1", "exports": { ".": "./index.ts", "./core": "./core.ts", diff --git a/package.json b/package.json index 123e199..77aad1d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "nostr-tools", - "version": "2.23.0", + "version": "2.23.1", "description": "Tools for making a Nostr client.", "repository": { "type": "git",