eth_getLogs returns null results sometimes

Quite irregularly eth_getLogs is returning null results about 2% of the time.

Given the following request:
curl --location --request POST 'https://mainnet.infura.io/v3/<project-id>' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "method": "eth_getLogs", "params": [ { "fromBlock": "0xCA9963", "toBlock": "0xE10F9B", "topics": [ "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9" ] } ], "id": 1 }'

I wrote a script that queries 100 times, and am seeing:
... {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"result":null} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"result":null} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} {"jsonrpc":"2.0","id":1,"error":{"code":-32005,"message":"query returned more than 10000 results"}} ...

With the response being {"jsonrpc":"2.0","id":1,"result":null} for about 1-3 times in those 100 calls.

Hey :wave: @friedemann and welcome to the Infura community!

There is some limitation on that call:

  • A max of 10,000 results can be returned by a single query

  • Query duration must not exceed 10 seconds

Suggestion for improvement:

  • Limit your query to a smaller number of blocks using fromBlock and toBlock .

  • If querying for commonly used topics , consider limiting to a single Smart Contract address as well.

Alternatively, you can try using JSON-RPC over WS.

Hi and thanks for your answer!

I’m aware of those limitations and as expected I get an error message in 98% of the cases. I’m only concerned about the times I get no error back as this leads to my application expecting that the call went through and the result is just empty.

{"jsonrpc":"2.0","id":1,"result":null}

Is not the expected response in those cases, as per your docs:

If a query returns too many results or exceeds the max query duration, one of the following errors is returned:

Which is not the case here, even though the request clearly failed.

I see what you are saying, not the best way to implement error handling.

Let me research it and bring it up to the team, if they will have any suggestions on this.

Could you share with us a script, by any chance?
Have you tried implementing it on ws, do you receive the same results?