From b4e094a6abc5581a533a28814eb5245d7f230d8a Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Fri, 26 Aug 2022 17:38:02 +0200 Subject: [PATCH] Fix context cancel defer Signed-off-by: Philip Laine --- internal/server/event_handlers.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/server/event_handlers.go b/internal/server/event_handlers.go index d0b8e7162..a319c09d9 100644 --- a/internal/server/event_handlers.go +++ b/internal/server/event_handlers.go @@ -64,7 +64,7 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request) cleanupMetadata(event) ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second) - defer cancel() + defer cancel() var allAlerts v1beta1.AlertList err = s.kubeClient.List(ctx, &allAlerts) @@ -265,6 +265,8 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request) } go func(n notifier.Interface, e events.Event) { + ctx, cancel := context.WithTimeout(r.Context(), 15*time.Second) + defer cancel() if err := n.Post(ctx, e); err != nil { maskedErrStr, maskErr := masktoken.MaskTokenFromString(err.Error(), token) if maskErr != nil {