events: don't explode when destroying a bus

Only attempt to close channels once, rather than per topic
they are subscribed to.
This commit is contained in:
Matthew Penner
2022-01-20 09:48:18 -07:00
parent 6d8c1d2225
commit 4ba5fe2866
4 changed files with 39 additions and 22 deletions

View File

@@ -146,12 +146,10 @@ func (h *Handler) listenForServerEvents(ctx context.Context) error {
break
}
// These functions will automatically close the channel if it hasn't been already.
h.server.Events().Off(eventChan, e...)
h.server.LogSink().Off(logOutput)
h.server.InstallSink().Off(installOutput)
close(eventChan)
close(logOutput)
close(installOutput)
// If the internal context is stopped it is either because the parent context
// got canceled or because we ran into an error. If the "err" variable is nil