From ff26c4273a061b7d2c84e7b74f1e0f9e0acc6eb0 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sun, 19 Apr 2026 20:14:20 +0200 Subject: [PATCH] refactor: pass context to `shutdownServer` --- backend/internal/bootstrap/router_bootstrap.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go index 48911343..5413304b 100644 --- a/backend/internal/bootstrap/router_bootstrap.go +++ b/backend/internal/bootstrap/router_bootstrap.go @@ -264,7 +264,7 @@ func runServer(ctx context.Context, config *serverConfig) error { notifySystemdReady() <-ctx.Done() - return shutdownServer(config.server) + return shutdownServer(ctx, config.server) } func startCertWatcher(ctx context.Context, certProvider *tlsCertProvider) (*fsnotify.Watcher, error) { @@ -321,10 +321,9 @@ func notifySystemdReady() { } } -func shutdownServer(srv *http.Server) error { - // Note we use the background context here as ctx has been canceled already - shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 5*time.Second) - shutdownErr := srv.Shutdown(shutdownCtx) //nolint:contextcheck +func shutdownServer(ctx context.Context, srv *http.Server) error { + shutdownCtx, shutdownCancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) + shutdownErr := srv.Shutdown(shutdownCtx) shutdownCancel() if shutdownErr != nil { // Log the error only (could be context canceled)