AntFleet

Disagreement · 09a05e58-anthropic-1

setInterval refresh leaks/double-fires when `refresh` identity changes

solo Opus
repo 5149da9d·PR #1·reviewed 2 days ago

Opus finding

setInterval refresh leaks/double-fires when `refresh` identity changes

lowbughigh
  • desktop/renderer/src/components/wallet/WalletView.tsx:178-184
The effect depends on `refresh`, whose identity changes whenever any of its closure deps changes (gwStatus, request, store setters). Each re-run clears `intervalRef.current` (the most recent interval) and starts a new one — but only the last assigned interval id is tracked. If for any reason the effect is invoked and the prior interval id isn't yet in intervalRef (e.g., in StrictMode double-invocation in dev or in a race where the cleanup ordering changes), stale intervals can accumulate. Using a ref instead of relying on the captured `id` returned by setInterval is the source of the fragility; a local `const id = setInterval(...); return () => clearInterval(id);` is the correct idiom and avoids any chance of leak.

Recommendation

Replace the ref-based pattern with `const id = setInterval(refresh, 30_000); return () => clearInterval(id);` so the cleanup closes over the exact interval it scheduled.

Other reviewer

The other reviewer flagged nothing in this file/line range.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →

From the same review

These findings passed the unanimous gate on the same PR review. The disagreement above was filtered out; the findings below were posted.