mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-10 05:09:03 +00:00
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.
This commit is contained in:
parent
ce64ab44ed
commit
344ce84a43
1 changed files with 3 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue