fix: noise protocol channel close race condition

This commit is contained in:
Prem Chaitanya Prathi 2023-08-04 17:19:53 +05:30
parent 42b2c0bc6d
commit 884f65ecdf
No known key found for this signature in database
1 changed files with 1 additions and 1 deletions

View File

@ -95,6 +95,7 @@ func (r *NoiseWakuRelay) Subscribe(ctx context.Context, contentTopic string) <-c
for {
select {
case <-ctx.Done():
close(sub.msgChan)
return
case env := <-sub.broadcastSub.Ch:
if env == nil {
@ -137,7 +138,6 @@ func (r *NoiseWakuRelay) Stop() {
for _, contentTopicSubscriptions := range r.subscriptionChPerContentTopic {
for _, c := range contentTopicSubscriptions {
c.broadcastSub.Unsubscribe()
close(c.msgChan)
}
}
}