diff --git a/packages/providers/src/fetch_json.ts b/packages/providers/src/fetch_json.ts index fe83961208..67a9caef8b 100644 --- a/packages/providers/src/fetch_json.ts +++ b/packages/providers/src/fetch_json.ts @@ -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; } @@ -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;