-
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Location
components/swap/swap-interface.tsx
Description
The swap interface enters an infinite loading state when fetching pools. If the underlying RPC call returns an empty array without throwing an error, the loading loop never terminates. As a result, the UI becomes permanently stuck, with no way for the user to reset or restart the swap flow.
This leads to browser freeze/crash and forces the user to hard refresh the page, resulting in a critical UX failure.
const loadAllPools = async (totalPoolsCount: number) => {
let currentLoaded = 0;
let allPools: RowPool[] = [ETH_ROW_POOL];
while (currentLoaded < totalPoolsCount) {
const startIndex = currentLoaded;
const endIndex = Math.min(
startIndex + ITEMS_PER_PAGE - 1,
totalPoolsCount - 1
);
const newPools = await contractClient.getPools(startIndex, endIndex);
// BUG: no termination when newPools is empty
allPools = [...allPools, ...newPools];
setTokens(allPools);
// currentLoaded never increases if newPools.length === 0
currentLoaded += newPools.length;
await new Promise((resolve) => setTimeout(resolve, 100));
}
setTokensInitialized(true);
};-
getPools()can return [] -
currentLoaded+=newPools.length→ adds 0 -
while (currentLoaded < totalPoolsCount) never becomes false
-
Loop runs forever → React state updates → browser freezes → hard refresh required
@kaneki003 check this out , Please assign
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels