Skip to content

Commit

Permalink
Merge pull request #1 from 19Nazar/add_handler_request
Browse files Browse the repository at this point in the history
fix: support non-200 RPC error
  • Loading branch information
19Nazar authored Oct 11, 2024
2 parents bc78d21 + d821783 commit 47aa671
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 47aa671

Please sign in to comment.