Severity: Low
Source
Multiple hooks — 11 orphaned timeouts total:
| File |
Line(s) |
What fires |
useDeposit.ts |
308 |
refreshSlab() at 2s |
useWithdraw.ts |
211 |
refreshSlab() at 2s |
useClosePosition.ts |
81, 177 |
setPhase("idle") at 2s (2 instances) |
useInitUser.ts |
132, 194, 272 |
refreshSlab() at 2s (3 instances) |
useTrade.ts |
397 |
refreshSlab() at 1.2s, 2.2s, 3.5s (3 instances) |
Description
All 11 timeouts fire callbacks without clearTimeout on cleanup. For the slab refresh ones, SlabProvider.parseSlab's cancelled guard prevents React state update warnings, but the RPC calls still execute and are discarded. For useClosePosition, the setPhase("idle") call may fire on an unmounted component.
Fix
Store timeout IDs in refs and clear them in a useEffect cleanup:
const timeoutRef = useRef<ReturnType<typeof setTimeout>>();
useEffect(() => () => { if (timeoutRef.current) clearTimeout(timeoutRef.current); }, []);
Severity: Low
Source
Multiple hooks — 11 orphaned timeouts total:
useDeposit.tsrefreshSlab()at 2suseWithdraw.tsrefreshSlab()at 2suseClosePosition.tssetPhase("idle")at 2s (2 instances)useInitUser.tsrefreshSlab()at 2s (3 instances)useTrade.tsrefreshSlab()at 1.2s, 2.2s, 3.5s (3 instances)Description
All 11 timeouts fire callbacks without
clearTimeouton cleanup. For the slab refresh ones,SlabProvider.parseSlab'scancelledguard prevents React state update warnings, but the RPC calls still execute and are discarded. ForuseClosePosition, thesetPhase("idle")call may fire on an unmounted component.Fix
Store timeout IDs in refs and clear them in a
useEffectcleanup: