eth/fetcher: fix flaky test by improving event unsubscription (#33950)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

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.
This commit is contained in:
Bosul Mun 2026-03-05 12:48:44 +09:00 committed by GitHub
parent ce64ab44ed
commit 344ce84a43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {