From 344ce84a431613014c09cb88cdb14514a5a778cf Mon Sep 17 00:00:00 2001 From: Bosul Mun Date: Thu, 5 Mar 2026 12:48:44 +0900 Subject: [PATCH] eth/fetcher: fix flaky test by improving event unsubscription (#33950) Eth currently has a flaky test, related to the tx fetcher. The issue seems to happen when Unsubscribe is called while sub is nil. It seems that chain.Stop() may be invoked before the loop starts in some tests, but the exact cause is still under investigation through repeated runs. I think this change will at least prevent the error. --- eth/fetcher/tx_fetcher.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index bc422e6abe..5817dfbcf5 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -442,7 +442,9 @@ func (f *TxFetcher) loop() { if f.chain != nil { headEventCh = make(chan core.ChainEvent, 10) sub := f.chain.SubscribeChainEvent(headEventCh) - defer sub.Unsubscribe() + if sub != nil { + defer sub.Unsubscribe() + } } for {