Skip to content

Commit

Permalink
fix: error handling of Serve/ServeTLS funcs (#397)
Browse files Browse the repository at this point in the history
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

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
<!-- add here the GitHub issue that this PR resolves if applicable -->

### Notes
<!-- any additional notes for this PR -->

### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->

### How to test
<!-- if applicable, add testing instructions under this section -->

Signed-off-by: Skye Gill <gill.skye95@gmail.com>
  • Loading branch information
skyerus authored Feb 10, 2023
1 parent feebbe2 commit 8923bf2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/service/connect_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8923bf2

Please sign in to comment.