From ac65a7cd87299b2096a3f231b5bde30def6f60d7 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Thu, 15 Jan 2026 13:56:17 +0100 Subject: [PATCH] eth/handler: fix blocking on stop Signed-off-by: Csaba Kiraly --- eth/handler.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/eth/handler.go b/eth/handler.go index 26c084c0ed..fc1c55776a 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -740,7 +740,17 @@ func (h *handler) txOnChainCacheLoop() { //Subscribe to chain events to know when transactions are added to chain headEventCh := make(chan core.ChainEvent, 10) sub := h.chain.SubscribeChainEvent(headEventCh) - defer sub.Unsubscribe() + defer func() { + sub.Unsubscribe() + // drain channel + for { + select { + case <-headEventCh: + default: + return + } + } + }() var oldHead *types.Header for { @@ -762,6 +772,8 @@ func (h *handler) txOnChainCacheLoop() { // exit when the subscription ends case <-sub.Err(): return + case <-h.quitSync: + return } } }