Skip to content

Commit

Permalink
Fix: nil dereference error in eventbus (#593)
Browse files Browse the repository at this point in the history
Resolve BE-1924
  • Loading branch information
nickpetrovic authored Oct 7, 2024
1 parent 471d921 commit 0df03a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/common/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ func (eb *EventBus) Claim(eventId string) (*Event, *RedisLock, bool) {
lockKey := fmt.Sprintf("%s:%s:%s", eventPrefix, eventId, eventLockSuffix)

lock = NewRedisLock(eb.rdb)
if err != nil {
return nil, nil, false
}

err = lock.Acquire(context.TODO(), lockKey, RedisLockOptions{
TtlS: eventLockTtlS,
Expand Down Expand Up @@ -157,7 +154,14 @@ func (eb *EventBus) receive(ctx context.Context, wg *sync.WaitGroup, eventType s
retry:
for {
select {
case m := <-messages:
case m, ok := <-messages:
if !ok {
log.Printf("Events subscription closed for type <%s>. Retrying ...\n", eventType)
time.Sleep(eventRetryDelay)
messages, errs = eb.rdb.Subscribe(ctx, eventChannelKey)
continue retry
}

eventId := m.Payload

event, lock, claimed := eb.Claim(eventId)
Expand Down

0 comments on commit 0df03a3

Please sign in to comment.