Skip to content

Commit

Permalink
fix: support non-200 RPC error
Browse files Browse the repository at this point in the history
  • Loading branch information
19Nazar committed Oct 10, 2024
1 parent bc78d21 commit d821783
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/providers/src/fetch_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const retryConfig = {
numOfAttempts: RETRY_NUMBER,
timeMultiple: BACKOFF_MULTIPLIER,
retry: (e: ProviderError) => {
if ([503, 408].includes(e.cause)) {
if ([500, 408].includes(e.cause)) {
return true;
}

Expand Down Expand Up @@ -60,10 +60,12 @@ export async function fetchJsonRpc(url: string, json: JsonRpcRequest, headers: o
throw new ProviderError(await res.text(), { cause: status });
}

if (status === 503) {
throw new ProviderError(`${url} unavailable`, { cause: status });
if (status === 500) {
throw new ProviderError(`Internal server error`, { cause: status });
} else if (status === 408) {
throw new ProviderError('Unused connection', { cause: status });
throw new ProviderError('Timeout error', { cause: status });
} else if (status === 400) {
throw new ProviderError('Request validation error', { cause: status });
}

return res;
Expand Down

0 comments on commit d821783

Please sign in to comment.