Skip to content
Open
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
15 changes: 15 additions & 0 deletions evm/evm-rpc/src/rpc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export class EvmRpcClient extends RpcClient {
if (this.isRpcRateLimitError(err)) {
return true
}
if (this.isUpstreamUnavailableError(err)) {
return true
}
if (this.isRpcInternalError(err)) {
return this.retryInternalServerErrors
}
Expand All @@ -49,6 +52,18 @@ export class EvmRpcClient extends RpcClient {
)
}

isUpstreamUnavailableError(err: RpcError): boolean {
// Load-balancing / aggregating providers (e.g. uniblock) report a transient
// "service unavailable" error when all of their upstream providers momentarily
// fail to fulfill a request. This is an availability problem (the HTTP 503
// analog), not a permanent one, so it must be retried rather than crash the
// ingestion process.
return (
err.code === -32503 || // JSON-RPC "service unavailable" code used by aggregating providers
/prevented the request from being fulfilled/i.test(err.message)
)
}

isRpcRateLimitError(err: RpcError): boolean {
return (
/rate limit|too many requests/i.test(err.message) ||
Expand Down
Loading