Fix panic on nil message

This commit is contained in:
James Mills 2022-04-03 07:52:42 +10:00
parent 9ee8d0f867
commit 42173343fa
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -484,9 +484,8 @@ func (mb *MessageBus) Subscribe(id, topic string, opts ...SubscribeOption) chan
var n int
log.Debugf("subscriber wants to start from %d", o.Index)
q.ForEach(func(item interface{}) error {
msg := item.(Message)
log.Debugf("found #%v", msg)
if msg.ID >= o.Index {
if msg, ok := item.(Message); ok && msg.ID >= o.Index {
log.Debugf("found #%v", msg)
ch <- msg
n++
}