fix: handle closed channels on unsubscribe (#1995)

This commit is contained in:
Livio Amstutz 2021-07-09 11:33:43 +02:00 committed by GitHub
parent 09b5c964cc
commit f7aa2f6b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -69,7 +69,10 @@ func (s *Subscription) Unsubscribe() {
}
}
}
close(s.Events)
_, ok := <-s.Events
if ok {
close(s.Events)
}
}
func MapEventsToV1Events(events []EventReader) []*models.Event {

View File

@ -67,5 +67,8 @@ func (s *Subscription) Unsubscribe() {
}
}
}
close(s.Events)
_, ok := <-s.Events
if ok {
close(s.Events)
}
}