From 8923bf2d407e18b65c188aef9bf7370fc74c3be2 Mon Sep 17 00:00:00 2001 From: Skye Gill Date: Fri, 10 Feb 2023 13:38:33 +0000 Subject: [PATCH] fix: error handling of Serve/ServeTLS funcs (#397) ## This PR Fixes error handling of Serve/ServeTLS being deferred until flagd shutdown. If an error occurred from one of these functions, it'd be ignored until shutdown. ### Related Issues ### Notes ### Follow-up Tasks ### How to test Signed-off-by: Skye Gill --- pkg/service/connect_service.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/service/connect_service.go b/pkg/service/connect_service.go index 49c5ae888..e413f2052 100644 --- a/pkg/service/connect_service.go +++ b/pkg/service/connect_service.go @@ -78,11 +78,13 @@ func (s *ConnectService) Serve(ctx context.Context, eval eval.IEvaluator) error } close(errChan) }() - <-ctx.Done() - if err := s.server.Shutdown(ctx); err != nil { + + select { + case err := <-errChan: return err + case <-ctx.Done(): + return s.server.Shutdown(ctx) } - return <-errChan } func (s *ConnectService) setupServer() (net.Listener, error) {