Skip to content

Commit c90d9b7

Browse files
committed
decrease batch size if response too large
1 parent 5a6a335 commit c90d9b7

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

evm/evm-data-service/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ runProgram(async () => {
9595
return mainWorker.getStream(req)
9696
}
9797
}
98-
98+
// dataSource = createDataSource(dataSourceOptions)
9999
let service = await runDataService({
100100
source: dataSource,
101101
blockCacheSize: args.blockCacheSize,

evm/evm-rpc/src/rpc.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ export class Rpc {
621621
if (batch.length <= 1) return this.batchCall(batch, options)
622622

623623
let result = await this.batchCall(batch, {...options, retryAttempts: 0}).catch(err => {
624-
if (this.client.isConnectionError(err) || err instanceof RpcProtocolError) {
624+
if (this.isRetryableError(err)) {
625625
this.log.warn(err, 'will retry request with reduced batch')
626626
} else {
627627
throw err
@@ -643,6 +643,14 @@ export class Rpc {
643643
let chainId: Qty = await this.call('eth_chainId')
644644
return this.chainUtils = new ChainUtils(chainId)
645645
}
646+
647+
isRetryableError(err: any): boolean {
648+
if (this.client.isConnectionError(err)) return true
649+
if (err instanceof RpcProtocolError) return true
650+
if (err instanceof RpcError && err.message == 'response too large') return true
651+
if (err instanceof RpcError && err.code == 429) return true
652+
return false
653+
}
646654
}
647655

648656

util/rpc-client/src/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,6 @@ export class RpcClient {
518518
if (err instanceof RpcConnectionError) return true
519519
if (isHttpConnectionError(err)) return true
520520
if (err instanceof HttpTimeoutError) return true
521-
if (err instanceof RpcError) {
522-
return err.code == 429
523-
}
524521
if (err instanceof HttpError) {
525522
switch(err.response.status) {
526523
case 408:
@@ -594,6 +591,7 @@ function isExecutionTimeoutError(err: unknown): boolean {
594591
return err instanceof RpcError && /execution timeout/i.test(err.message)
595592
}
596593

594+
597595
function isRequestTimedOutError(err: unknown): boolean {
598596
return err instanceof RpcError && /request.*timed out/i.test(err.message)
599597
}

0 commit comments

Comments
 (0)