Skip to content

Commit

Permalink
pubsub: Report a non-nil error when shutting down. (#7309)
Browse files Browse the repository at this point in the history
If a subscriber arrives while the pubsub service is shutting down, the existing
code will return a nil subscription without error. With unlucky timing, this
may lead to a nil indirection panic in the RPC service.

To avoid that problem, make sure that when a subscription fails for this
reason, we report a non-nil error so that the client will detect it and give up
gracefully.

Co-authored-by: M. J. Fromberger <[email protected]>
  • Loading branch information
tnasu and M. J. Fromberger committed Feb 25, 2022
1 parent b80e5ef commit e827e8d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (s *Server) subscribe(ctx context.Context, clientID string, query Query, ou
case <-ctx.Done():
return nil, ctx.Err()
case <-s.Quit():
return nil, nil
return nil, errors.New("service is shutting down")
}
}

Expand Down

0 comments on commit e827e8d

Please sign in to comment.