Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evm: handle logs response is too big error #364

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/evm-processor",
"comment": "handle logs response is too big error",
"type": "minor"
}
],
"packageName": "@subsquid/evm-processor"
}
10 changes: 6 additions & 4 deletions evm/evm-processor/src/ds-rpc/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class Rpc {
throw new RpcError(info)
}
}).catch(async err => {
if (isQueryReturnedMoreThanNResultsError(err)) {
if (isLogsResponseTooBigError(err)) {
let range = asTryAnotherRangeError(err)
if (range == null) {
range = {from, to: Math.floor(from + (to - from) / 2)}
Expand Down Expand Up @@ -746,14 +746,16 @@ class RpcProps {
}
}

function isQueryReturnedMoreThanNResultsError(err: unknown) {
function isLogsResponseTooBigError(err: unknown) {
if (!(err instanceof RpcError)) return false
return /query returned more than/i.test(err.message)
if (/query returned more than/i.test(err.message)) return true
if (/response is too big/i.test(err.message)) return true
return false
}

function asTryAnotherRangeError(err: unknown): FiniteRange | undefined {
if (!(err instanceof RpcError)) return
let m = /Try with this block range \[(0x[0-9a-f]+), (0x[0-9a-f]+)]/i.exec(err.message)
let m = /try with this block range \[(0x[0-9a-f]+), (0x[0-9a-f]+)]/i.exec(err.message)
if (m == null) return
let from = qty2Int(m[1])
let to = qty2Int(m[2])
Expand Down
Loading