From 58696fa2ae5af10a6b0e8169210c533029f4792e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 16:18:13 +0000 Subject: [PATCH] eth/filters: fix race in NewPendingTransactions and NewHeads subscriptions Co-authored-by: s1na <1591639+s1na@users.noreply.github.com> --- eth/filters/api.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index f4bed35b26..015622527e 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -189,9 +189,10 @@ func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool) rpcSub := notifier.CreateSubscription() + txs := make(chan []*types.Transaction, 128) + pendingTxSub := api.events.SubscribePendingTxs(txs) + go func() { - txs := make(chan []*types.Transaction, 128) - pendingTxSub := api.events.SubscribePendingTxs(txs) defer pendingTxSub.Unsubscribe() chainConfig := api.sys.backend.ChainConfig() @@ -262,9 +263,10 @@ func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) { rpcSub := notifier.CreateSubscription() + headers := make(chan *types.Header) + headersSub := api.events.SubscribeNewHeads(headers) + go func() { - headers := make(chan *types.Header) - headersSub := api.events.SubscribeNewHeads(headers) defer headersSub.Unsubscribe() for {