go-ethereum/eth/filters
Copilot de0a452f7d
eth/filters: fix race in pending tx and new heads subscriptions (#33990)
`TestSubscribePendingTxHashes` hangs indefinitely because pending tx
events are permanently missed due to a race condition in
`NewPendingTransactions` (and `NewHeads`). Both handlers called their
event subscription functions (`SubscribePendingTxs`,
`SubscribeNewHeads`) inside goroutines, so the RPC handler returned the
subscription ID to the client before the filter was installed in the
event loop. When the client then sent a transaction, the event fired but
no filter existed to catch it — the event was silently lost.

- Move `SubscribePendingTxs` and `SubscribeNewHeads` calls out of
goroutines so filters are installed synchronously before the RPC
response is sent, matching the pattern already used by `Logs` and
`TransactionReceipts`

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: s1na <1591639+s1na@users.noreply.github.com>
2026-03-12 10:21:45 +08:00
..
api.go eth/filters: fix race in pending tx and new heads subscriptions (#33990) 2026-03-12 10:21:45 +08:00
api_test.go eth/filters, cmd: add config of eth_getLogs address limit (#32327) 2025-09-19 00:53:40 +02:00
filter.go rpc: add a rpc.rangelimit flag (#33163) 2026-01-17 14:34:08 +01:00
filter_system.go rpc: add a rpc.rangelimit flag (#33163) 2026-01-17 14:34:08 +01:00
filter_system_test.go core/state, core/tracing: new state update hook (#33490) 2026-01-08 11:07:19 +08:00
filter_test.go rpc: add a rpc.rangelimit flag (#33163) 2026-01-17 14:34:08 +01:00