fix: panic in broadcast when logout (#4475)
This commit is contained in:
parent
a5f6a6c2f6
commit
e5ce11f067
|
@ -1030,7 +1030,9 @@ func (w *Waku) broadcast() {
|
|||
var fn publishFn
|
||||
if w.settings.SkipPublishToTopic {
|
||||
// For now only used in testing to simulate going offline
|
||||
fn = func(env *protocol.Envelope, logger *zap.Logger) error { return errors.New("test send failure") }
|
||||
fn = func(env *protocol.Envelope, logger *zap.Logger) error {
|
||||
return errors.New("test send failure")
|
||||
}
|
||||
} else if w.settings.LightClient {
|
||||
fn = func(env *protocol.Envelope, logger *zap.Logger) error {
|
||||
logger.Info("publishing message via lightpush")
|
||||
|
@ -1045,6 +1047,7 @@ func (w *Waku) broadcast() {
|
|||
}
|
||||
}
|
||||
|
||||
w.wg.Add(1)
|
||||
go w.publishEnvelope(envelope, fn, logger)
|
||||
case <-w.ctx.Done():
|
||||
return
|
||||
|
@ -1055,6 +1058,8 @@ func (w *Waku) broadcast() {
|
|||
type publishFn = func(envelope *protocol.Envelope, logger *zap.Logger) error
|
||||
|
||||
func (w *Waku) publishEnvelope(envelope *protocol.Envelope, publishFn publishFn, logger *zap.Logger) {
|
||||
defer w.wg.Done()
|
||||
|
||||
var event common.EventType
|
||||
if err := publishFn(envelope, logger); err != nil {
|
||||
logger.Error("could not send message", zap.Error(err))
|
||||
|
|
Loading…
Reference in New Issue