Skip to content

Commit

Permalink
evm: handle logs response is too big error (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash authored Jan 3, 2025
1 parent 14eb845 commit 0b83ed5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
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

0 comments on commit 0b83ed5

Please sign in to comment.