Skip to content

Commit

Permalink
node: fix HTTP server always force closing (ethereum#25755)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
2 people authored and cp-wjhan committed Jan 26, 2024
1 parent 2fcc34a commit 60b3fb7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion node/rpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 60b3fb7

Please sign in to comment.