fix(nostr): close SimplePool after publishing to prevent connection leak
Each sendEvent() call created a new SimplePool() but never closed it, causing relay WebSocket connections to accumulate indefinitely (~20/min). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6512e10f08
commit
611eb4fc04
1 changed files with 17 additions and 13 deletions
|
|
@ -205,6 +205,7 @@ export class NostrPool {
|
||||||
const log = getLogger({ appName: keys.name })
|
const log = getLogger({ appName: keys.name })
|
||||||
this.log(`📤 Publishing Kind ${event.kind} event to ${relays.length} relay(s): ${relays.join(', ')}`)
|
this.log(`📤 Publishing Kind ${event.kind} event to ${relays.length} relay(s): ${relays.join(', ')}`)
|
||||||
const pool = new SimplePool()
|
const pool = new SimplePool()
|
||||||
|
try {
|
||||||
await Promise.all(pool.publish(relays, signed).map(async p => {
|
await Promise.all(pool.publish(relays, signed).map(async p => {
|
||||||
try {
|
try {
|
||||||
await p
|
await p
|
||||||
|
|
@ -220,6 +221,9 @@ export class NostrPool {
|
||||||
} else {
|
} else {
|
||||||
this.log(`✅ Kind ${event.kind} event published successfully (id: ${signed.id.slice(0, 16)}...)`)
|
this.log(`✅ Kind ${event.kind} event published successfully (id: ${signed.id.slice(0, 16)}...)`)
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
pool.close(relays)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRelays(initiator: SendInitiator, requestRelays?: string[]) {
|
private getRelays(initiator: SendInitiator, requestRelays?: string[]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue