diff --git a/src/components/pages/DaoHierarchy/useFetchNodes.tsx b/src/components/pages/DaoHierarchy/useFetchNodes.tsx index f3f5790016..7b5be8631b 100644 --- a/src/components/pages/DaoHierarchy/useFetchNodes.tsx +++ b/src/components/pages/DaoHierarchy/useFetchNodes.tsx @@ -96,7 +96,7 @@ export function useFetchNodes(address?: string) { for await (const subDAO of nodes) { try { const safeInfo = await requestWithRetries(() => fetchDAOInfo(subDAO.address), 5, 5000); - if (safeInfo.guard) { + if (safeInfo && safeInfo.guard) { if (safeInfo.guard === ethers.constants.AddressZero) { subDAOs.push(safeInfo); } else { diff --git a/src/hooks/DAO/loaders/governance/useAzoriusProposals.ts b/src/hooks/DAO/loaders/governance/useAzoriusProposals.ts index 6928af6f11..127fa75646 100644 --- a/src/hooks/DAO/loaders/governance/useAzoriusProposals.ts +++ b/src/hooks/DAO/loaders/governance/useAzoriusProposals.ts @@ -167,10 +167,12 @@ export const useAzoriusProposals = () => { ); }; const proposal = await requestWithRetries(func, 5, 7000); - action.dispatch({ - type: FractalGovernanceAction.UPDATE_PROPOSALS_NEW, - payload: proposal, - }); + if (proposal) { + action.dispatch({ + type: FractalGovernanceAction.UPDATE_PROPOSALS_NEW, + payload: proposal, + }); + } }, [ baseContracts, diff --git a/src/hooks/utils/useAsyncRetry.ts b/src/hooks/utils/useAsyncRetry.ts index 9ed3f83345..9b7258333e 100644 --- a/src/hooks/utils/useAsyncRetry.ts +++ b/src/hooks/utils/useAsyncRetry.ts @@ -5,15 +5,9 @@ function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } -export type RequestWithRetries = ( - func: () => Promise, - retries: number, - secondsToWait?: number, -) => Promise; - export function useAsyncRetry() { - const requestWithRetries: RequestWithRetries = useCallback( - async (func: () => Promise, retries: number, secondsToWait: number = 2000) => { + const requestWithRetries = useCallback( + async (func: () => Promise, retries: number, secondsToWait: number = 2000) => { let currentRetries = 0; let result = null;