Skip to content

fix: set fromBlock latest on eth_newFilter for event listeners - #5181

Open
official-burak wants to merge 1 commit into
ethers-io:mainfrom
official-burak:fix/eth-newfilter-fromblock-latest
Open

fix: set fromBlock latest on eth_newFilter for event listeners#5181
official-burak wants to merge 1 commit into
ethers-io:mainfrom
official-burak:fix/eth-newfilter-fromblock-latest

Conversation

@official-burak

@official-burak official-burak commented Aug 19, 2026

Copy link
Copy Markdown

Fixes #5061.

FilterIdEventSubscriber sends eth_newFilter with only address and topics. The JSON-RPC spec defaults fromBlock to latest, but some providers (Chainstack and others with historical range limits) treat a missing fromBlock as an unbounded range and reject the request. That makes contract.on() / provider.on(filter) fail even though the listener only needs new logs.

When the filter does not already specify fromBlock, this sets fromBlock: "latest" so live subscriptions match the spec default and those providers.

Existing explicit fromBlock values are left unchanged. Test uses the in-process JsonRpc mock from test-providers-jsonrpc.ts.

Some RPC providers reject eth_newFilter without an explicit fromBlock as an unbounded historical range, which breaks contract.on(). The JSON-RPC default is latest; send it explicitly when the filter does not already set fromBlock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contract.on() fails on Chainstack with block range limit error - eth_newFilter should include fromBlock: "latest"

1 participant