Skip to content

Commit

Permalink
Fix context cancel defer
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <philip.laine@gmail.com>
  • Loading branch information
phillebaba committed Aug 26, 2022
1 parent 57128d9 commit 1857158
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/server/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request)
cleanupMetadata(event)

ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second)
defer cancel()

var allAlerts v1beta1.AlertList
err = s.kubeClient.List(ctx, &allAlerts)
Expand Down Expand Up @@ -265,6 +264,7 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request)
}

go func(n notifier.Interface, e events.Event) {
defer cancel()
if err := n.Post(ctx, e); err != nil {
maskedErrStr, maskErr := masktoken.MaskTokenFromString(err.Error(), token)
if maskErr != nil {
Expand Down

0 comments on commit 1857158

Please sign in to comment.