fix(GODT-3116): Panic on closed channel

If sync finishes during shutdown, check if there is a context error in
the deferred go routine before rewinding the event.
This commit is contained in:
Leander Beernaert 2023-11-10 14:47:03 +01:00
parent ff288145df
commit 856bdd1321
1 changed files with 5 additions and 0 deletions

View File

@ -395,6 +395,11 @@ func (s *Service) run(ctx context.Context) { //nolint gocyclo
// event service is unable to reply to the request until the events have been processed.
s.log.Info("Sync complete, starting API event stream")
go func() {
// If context cancelled do not do anything
if ctx.Err() != nil {
return
}
if err := s.eventProvider.RewindEventID(ctx, s.lastHandledEventID); err != nil {
if errors.Is(err, context.Canceled) {
return