From 6c10996bf5664ea2a7f7020bcb4d97a848dbf48a Mon Sep 17 00:00:00 2001 From: jwasinger Date: Tue, 21 Jan 2025 20:11:05 +0800 Subject: [PATCH] eth/filters: ensure API timeoutLoop terminates with event system (#31056) Discovered from failing test introduced https://github.com/ethereum/go-ethereum/pull/31033 . We should ensure `timeoutLoop` terminates if the filter event system is terminated. --- eth/filters/api.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index f46dd39dd8..e3057a2af2 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -90,7 +90,11 @@ func (api *FilterAPI) timeoutLoop(timeout time.Duration) { ticker := time.NewTicker(timeout) defer ticker.Stop() for { - <-ticker.C + select { + case <-ticker.C: + case <-api.events.chainSub.Err(): + return + } api.filtersMu.Lock() for id, f := range api.filters { select {