Skip to content

Commit

Permalink
don't throw on "Too many requests" error from 3rd-party APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Feb 6, 2025
1 parent e5829cf commit 42c1a96
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/api/useQueryClientConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,26 @@ export default function useQueryClientConfig() {
queries: {
refetchOnWindowFocus: false,
retry,
throwOnError: (error) => {
throwOnError: (error, query) => {
const status = getErrorObjStatusCode(error);
// don't catch error for "Too many requests" response
return status === 429;

// we don't catch error only for "Too many requests" response
if (status !== 429) {
return false;
}

const EXTERNAL_API_RESOURCES = [
'safe_transaction_api',
'contract_solidity_scan_report',
'address_xstar_score',
'noves_transaction',
'noves_address_history',
'noves_describe_txs',
'gas_hawk_saving_potential',
];
const isExternalApiResource = EXTERNAL_API_RESOURCES.some((resource) => query.queryKey[0] === resource);

return !isExternalApiResource;
},
},
},
Expand Down

0 comments on commit 42c1a96

Please sign in to comment.