How to Fix eth_getLogs Timeouts and Query Error
DevRel
August 13, 2026
11 min read
Say you want to pull every Transfer event for a token since it launched. You write one call, set fromBlock to 0 and toBlock to "latest", and run it. Instead of a nice array of logs, you get this back:
1
2
3
4
5
6
7
8
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32062,
"message": "Block range is too large"
}
}
Or the request just hangs for a while and comes back with "request timed out."
This trips up almost everyone the first time they query logs at scale. The good news is that it is not a bug in your code. Once you understand what the node is doing when you call eth_getLogs, the fix becomes simple and mechanical. Here is how it works, step by step.
TL;DR
eth_getLogs fails on big queries because nodes and providers cap how much a single query can return and how long it can run. There is no one standard limit. Every provider picks its own.
You will meet two kinds of failure: "too many results" (the response was too big) and "timed out" (the query was too slow). They need different fixes, so read the error before you react.
The main fix is to split your block range into smaller chunks and query them one at a time. If a chunk is still too big, cut it in half and try again.
You can also shrink the response by filtering on a contract address and specific topics, so the node returns only the logs you actually want.
For live data, stop polling and subscribe over WebSocket. For large historical backfills, reach for an indexer instead of raw eth_getLogs.
What is eth_getLogs actually doing?
Every time a smart contract emits an event, the node records it as a log. To make logs searchable without scanning every transaction, each block header carries a small summary called a bloom filter. Think of it as a fingerprint for the block that answers one question quickly: "could this block contain a log for this address or topic?" It can say "definitely not" or "maybe," and that is enough to skip most blocks fast.
When you call eth_getLogs over a range, the node walks through the range block by block. For each block, it checks the bloom filter, and for the blocks that look promising, it reads the full logs and matches them against your filter. So a query over one million blocks means one million of these checks; even if only three blocks actually hold a log you want.
That single fact explains both errors. A wide range makes the node do a lot of work, which is why it can time out. A busy range (think Transfer events on a popular token) returns a huge pile of logs, which is why you hit the "too many results" cap. Keep this picture in mind and the fixes will feel obvious.
Why is one query not enough
Here is the part that confuses people. There is no rule in the Ethereum protocol that says "eth_getLogs may return at most N results." The limits you keep hitting are chosen by whoever runs the node, and they exist to stop one heavy query from hogging the server.
That means two layers can reject your query:
The node client itself. Clients like Geth scan that bloom index and enforce their own timeouts, so a slow query gets cut off.
The provider gateway in front of the node. Public and commercial endpoints add their own caps on top, either on the block range or on the number of logs returned.
Because each endpoint sets its own numbers, the same query that works in one place fails in another. Endpoints tend to cap in one of two ways, and sometimes both:
By result count: A common cap is 10,000 logs per query, which is why the "query returned more than 10000 results" message appears.
By block range: The endpoint refuses any range wider than a set number of blocks, whether or not it contains many logs. GetBlock, for example, caps eth_getLogs at 1,500 blocks per call.
Read the error before you fix it
When a log query fails, resist the urge to blindly shrink everything. The error tells you which wall you hit, and the two walls have different fixes.
You hit a results cap when the message looks like this:
1
{ "code": -32005, "message": "query returned more than 10000 results" }
You hit a block range limit when the message is about the width of the range rather than the number of results. The exact wording varies by endpoint, but it looks something like this:
1
{ "code": -32602, "message": "query exceeds max block range" }
And you hit a timeout when the query was too slow rather than too big:
1
{ "code": -32002, "message": "request timed out" }
GetBlock also has a different error here aside from the JSON-RPC error shape for this case. If you ask for a range wider than its limit, the endpoint replies with an HTTP 403 Forbidden and this body:
1
{ "error": "Requested block range exceeds the limits (1500 blocks)" }
Two things to take from that. First, GetBlock caps eth_getLogs at 1,500 blocks per call, so keep your chunks under it.
Second, because this comes back as a 403 rather than a JSON-RPC error, ethers reports it as a SERVER_ERROR and puts the real reason in err.info.responseBody, not in err.message. Your error handling has to look there, which the helper in the next section does.
How to Fix These Errors
1: Split the range into chunks
The simplest reliable fix is pagination. Instead of asking for one giant range, ask for many small ranges and stitch the results together. Here is a first version in ethers v6:
1
2
3
4
5
6
7
8
9
10
11
12
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider(process.env.GETBLOCK_RPC_URL);
async function getLogsChunked(filter, fromBlock, toBlock, chunkSize = 1000) {
const all = [];
for (let start = fromBlock; start <= toBlock; start += chunkSize) {
const end = Math.min(start + chunkSize - 1, toBlock);
const logs = await provider.getLogs({ ...filter, fromBlock: start, toBlock: end }); all.push(...logs);
console.log(`blocks ${start} to ${end}: ${logs.length} logs`);
}
return all;
}
The default chunk is 1,000 blocks on purpose. GetBlock caps eth_getLogs at 1,500 blocks per call, and 1,000 leaves comfortable headroom, so set this number to whatever your endpoint allows. This already works for most cases. But it has a weakness. If one window happens to hold more logs than the endpoint's result cap (say, a mint event during a busy launch fills it up), that window still fails. The next version handles that.
2: Make your chunks adaptive
The trick is to catch the failure, cut the failing window in half, and retry each half. Keep halving until each piece is small enough to succeed. This way your code adapts to any provider limit without you hardcoding a single number.
Start with a small helper that recognizes the "too much" errors shown above. It checks a few of the places ethers tucks the message, then looks for the phrases those errors have in common:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function looksLikeTooMuch(err) {
const raw = [
err?.shortMessage,
err?.message,
err?.info?.responseBody, // GetBlock: {"error":"Requested block range exceeds the limits (1500 blocks)"}
err?.info?.error?.message,
err?.error?.message,
].filter(Boolean).join(" ").toLowerCase();
return [
"more than", // query returned more than 10000 results
"response size", // Log response size exceeded
"limit exceeded", // Limit exceeded
"block range", // query exceeds max block range / Requested block range exceeds the limits "exceeds the limits", // GetBlock's exact wording
"too large", // range is too large
"timed out", // request timed out
"timeout",
].some((phrase) => raw.includes(phrase));
}
Now the adaptive version. When a window fails, it splits into two halves and recurses:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
async function getLogsAdaptive(filter, fromBlock, toBlock, chunkSize = 1000) {
const all = [];
for (let start = fromBlock; start <= toBlock; start += chunkSize) {
const end = Math.min(start + chunkSize - 1, toBlock);
try {
const logs = await provider.getLogs({ ...filter, fromBlock: start, toBlock: end });
all.push(...logs);
} catch (err) {
if (looksLikeTooMuch(err) && end > start) {
const mid = Math.floor((start + end) / 2);
const left = await getLogsAdaptive(filter, start, mid, chunkSize);
const right = await getLogsAdaptive(filter, mid + 1, end, chunkSize);
all.push(...left, ...right);
} else {
throw err;
}
}
}
return all;
}
Read the catch block slowly, because it is the whole idea. If the window failed for a "too much" reason and it is wider than a single block, split it and try both halves. If it failed for some other reason, or it is already a single block that still will not fit, throw, because no amount of splitting will help there. That single block case is rare, but it is a real limit worth knowing: nothing you do to the range fixes a single block that alone exceeds the cap.
If you want to go one step further, you can read the suggested range straight out of the error data field that newer nodes return, and jump directly to it instead of halving. Halving is simpler and works everywhere, so start there and optimize later if you need to.
3: Ask for less in the first place
Chunking controls how wide you query. Filtering controls how much each query returns. Used together, they are far more effective than either alone.
If you only care about one contract, always set the address. If you only care about one event, add its topic. The topic is the keccak256 hash of the event signature, and ethers can compute it for you:
1
2
3
4
5
6
7
8
9
const dai = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
const transferTopic = ethers.id("Transfer(address,address,uint256)");
const filter = {
address: dai,
topics: [transferTopic],
};
const logs = await getLogsAdaptive(filter, 18000000, 18100000);
By naming the address and the topic, you tell the node to skip everything else, so the response is smaller, and you are far less likely to trip the results cap. You can go tighter still. Topics are position-based, so a second topic filters by the indexed "from" address, a third by the indexed "to" address, and so on.
One more filter worth knowing. If you want the logs from exactly one block, pass blockHash instead of a fromBlock and toBlock pair. It scopes the query to that single block. Just remember you cannot combine blockHash with a range; it is one or the other.
When eth_getLogs is the wrong tool
Sometimes the right fix is to stop calling eth_getLogs so much.
If you want to react to new events as they happen, do not poll a range on a loop. Subscribe over a WebSocket connection and let the node push each matching log to you:
1
2
3
4
5
const wss = new ethers.WebSocketProvider(process.env.GETBLOCK_WSS_URL);
wss.on(
{ address: dai, topics: [ethers.id("Transfer(address,address,uint256)")] }, (log) => console.log("new transfer", log.transactionHash),
);
And if you need to pull millions of historical logs, or you run the same heavy query again and again, indexing is the better pattern. You index the logs once into your own store and query that, instead of replaying the same wide query on every request. An indexer still needs a reliable archive endpoint underneath to sync from, which is what GetBlock's Archive Mode gives you on EVM chains. On Solana, GetBlock's Indexed Archive goes further and hands you a pre-indexed history of blocks, transactions, and logs through a single API, so you skip building the index yourself. Raw eth_getLogs stays perfect for targeted reads. It is the wrong tool for a full historical backfill.
Conclusion
Here is the whole approach in one place. eth_getLogs fails on large queries for two reasons: the query is too slow, or the response is too big. Nodes and providers set their own limits to protect themselves, and those limits vary, so your code should adapt rather than assume. Read the error to see which wall you hit. Chunk the block range, and make the chunks adaptive so a busy window splits itself. Filter by address and topic so each query returns less. And when you are following live events or backfilling history, switch to subscriptions or an indexer.
Do those things and the errors that stopped you today stop being errors. They become a size your code already knows how to handle.
If you want an endpoint to build this on, GetBlock gives you HTTP and WebSocket access across a long list of chains, so the same code above works whether you are reading logs on Ethereum, Base, BSC, or somewhere newer. Create a free account, grab an endpoint, and try the adaptive function on a range that used to fail.
DevRel
August 13, 2026
11 min read
DevRel at GetBlock with over five years of experience in building and writing developer documentation.
Popular Posts
December 4, 2026
8 分鐘閱讀
September 14, 2026
4 分鐘閱讀