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
cc9aa49b5b
commit
48ee930b36
1 changed files with 17 additions and 13 deletions
|
|
@ -205,6 +205,7 @@ export class NostrPool {
|
|||
const log = getLogger({ appName: keys.name })
|
||||
this.log(`📤 Publishing Kind ${event.kind} event to ${relays.length} relay(s): ${relays.join(', ')}`)
|
||||
const pool = new SimplePool()
|
||||
try {
|
||||
await Promise.all(pool.publish(relays, signed).map(async p => {
|
||||
try {
|
||||
await p
|
||||
|
|
@ -220,6 +221,9 @@ export class NostrPool {
|
|||
} else {
|
||||
this.log(`✅ Kind ${event.kind} event published successfully (id: ${signed.id.slice(0, 16)}...)`)
|
||||
}
|
||||
} finally {
|
||||
pool.close(relays)
|
||||
}
|
||||
}
|
||||
|
||||
private getRelays(initiator: SendInitiator, requestRelays?: string[]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue