From 25b35c97289a8db4753cdf5ab7f2b306ec71794d Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Wed, 14 Sep 2022 18:37:53 +0200 Subject: [PATCH] node: fix HTTP server always force closing (#25755) Co-authored-by: Felix Lange --- node/rpcstack.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/rpcstack.go b/node/rpcstack.go index 5d411fa61e..f45435bab2 100644 --- a/node/rpcstack.go +++ b/node/rpcstack.go @@ -267,13 +267,15 @@ func (h *httpServer) doStop() { h.wsHandler.Store((*rpcHandler)(nil)) wsHandler.server.Stop() } + ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout) defer cancel() err := h.server.Shutdown(ctx) - if err == ctx.Err() { + if err != nil && err == ctx.Err() { h.log.Warn("HTTP server graceful shutdown timed out") h.server.Close() } + h.listener.Close() h.log.Info("HTTP server stopped", "endpoint", h.listener.Addr())