From 7320b1be75944a66fdb165169eb3b56af419b974 Mon Sep 17 00:00:00 2001 From: fazledyn-or Date: Wed, 31 Jan 2024 16:46:32 +0600 Subject: [PATCH] Added cancel method call to avoid context leak Signed-off-by: fazledyn-or --- cmd/pipecd/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/pipecd/server.go b/cmd/pipecd/server.go index b0ec9e96f4..e2c06f8db5 100644 --- a/cmd/pipecd/server.go +++ b/cmd/pipecd/server.go @@ -402,7 +402,8 @@ func runHTTPServer(ctx context.Context, httpServer *http.Server, gracePeriod tim <-ctx.Done() - ctx, _ = context.WithTimeout(context.Background(), gracePeriod) + ctx, cancel = context.WithTimeout(context.Background(), gracePeriod) + defer cancel() logger.Info("stopping http server") if err := httpServer.Shutdown(ctx); err != nil { logger.Error("failed to shutdown http server", zap.Error(err))