From 5d1d3cc9e623b573c4b96635fde8a70f2520dece Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 5 Feb 2022 12:11:00 -0500 Subject: [PATCH] Fix panic conditions --- router/websocket/listeners.go | 5 ++++- server/listeners.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/router/websocket/listeners.go b/router/websocket/listeners.go index ecb557e..9387c96 100644 --- a/router/websocket/listeners.go +++ b/router/websocket/listeners.go @@ -125,7 +125,10 @@ func (h *Handler) listenForServerEvents(ctx context.Context) error { } onError(server.InstallOutputEvent, sendErr) case b := <-eventChan: - e := events.MustDecode(b) + var e events.Event + if err := events.DecodeTo(b, &e); err != nil { + continue + } var sendErr error message := Message{Event: e.Topic} if str, ok := e.Data.(string); ok { diff --git a/server/listeners.go b/server/listeners.go index 81d05be..525e921 100644 --- a/server/listeners.go +++ b/server/listeners.go @@ -93,7 +93,10 @@ func (s *Server) StartEventListeners() { select { case v := <-c: go func(v []byte, limit *diskSpaceLimiter) { - e := events.MustDecode(v) + var e events.Event + if err := events.DecodeTo(v, &e); err != nil { + return + } switch e.Topic { case environment.ResourceEvent: {