From e0ed40613d8a48e9bad781db9f2baefa3284e782 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 12 Feb 2025 14:32:22 -0300 Subject: [PATCH] pool: bug that was causing a SubMany() to close if any of the relays failed to connect. fixes https://github.com/nbd-wtf/go-nostr/issues/172 --- pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pool.go b/pool.go index 983c329..f691448 100644 --- a/pool.go +++ b/pool.go @@ -254,7 +254,7 @@ func (pool *SimplePool) subMany( eoseChan chan struct{}, opts ...SubscriptionOption, ) chan RelayEvent { - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancelCause(ctx) _ = cancel // do this so `go vet` will stop complaining events := make(chan RelayEvent) seenAlready := xsync.NewMapOf[string, Timestamp]() @@ -288,11 +288,11 @@ func (pool *SimplePool) subMany( pending.Dec() if pending.Value() == 0 { close(events) + cancel(fmt.Errorf("aborted: %w", context.Cause(ctx))) } if !eosed { eoseWg.Done() } - cancel() }() hasAuthed := false