diff --git a/.changeset/healthy-bees-shout.md b/.changeset/healthy-bees-shout.md new file mode 100644 index 0000000000..9ba24588aa --- /dev/null +++ b/.changeset/healthy-bees-shout.md @@ -0,0 +1,5 @@ +--- +"@near-js/providers": patch +--- + +retry RPC request on 408 HTTP error diff --git a/packages/providers/src/fetch_json.ts b/packages/providers/src/fetch_json.ts index bef1a029dc..57ee7a9766 100644 --- a/packages/providers/src/fetch_json.ts +++ b/packages/providers/src/fetch_json.ts @@ -38,6 +38,9 @@ export async function fetchJson(connectionInfoOrUrl: string | ConnectionInfo, js if (response.status === 503) { logWarning(`Retrying HTTP request for ${connectionInfo.url} as it's not available now`); return null; + } else if (response.status === 408) { + logWarning(`Retrying HTTP request for ${connectionInfo.url} as the previous connection was unused for some time`); + return null; } throw createError(response.status, await response.text()); }