useSmartPolling's backoff only updates currentIntervalRef — the running setInterval never slows down, yet isBackingOff flips isLive to false
Maintainers usually reply within 1 day
@Biglamar is already working on this.
Since Sep 27, 2026.
Assessment
This issue has not been assessed yet.
Description
Problem
When the data is unchanged unchangedThreshold times in a row, useSmartPolling computes a longer interval:
const newInterval = Math.min(currentIntervalRef.current * backoffMultiplier, maxBackoff);
if (newInterval > currentIntervalRef.current) {
currentIntervalRef.current = newInterval;
dispatch({ type: 'START_BACKOFF' });
}
But the interval is only ever created with setInterval(fetchData, currentIntervalRef.current): at mount, and again when the tab becomes visible. Changing currentIntervalRef.current afterwards has no effect on the running timer. setInterval captured the delay when it was created. The same is true in reverse: refetch() and a detected change reset the ref back to interval, but the timer isn't rescheduled.
Impact
- The documented goal of backing off to 30s (
maxBackoff: 30000inuseBountyStatus) to reduce load on a quiet bounty never happens. Requests keep going out every 5s (BountyStatus) or every 2s (ClaimButton) for as long as the page is open. isBackingOffstill becomestrue, anduseBountyStatuscomputesisLive: isPolling && !isBackingOff. SoBountyStatusstops showing the "live" indicator while the hook is in fact still polling at full speed. The UI reports the opposite of what's actually happening.
Suggested fix
Reschedule whenever the effective interval changes:
- use a self-scheduling
setTimeoutchain that readscurrentIntervalRef.currenteach time, - or
clearIntervalplus a newsetIntervalinside the backoff and reset branches.
Add a fake-timer test: with an unchanged fetchFn, after the threshold the gap between calls grows, up to maxBackoff, and it resets after a change or refetch().
Related: #46, #359. This is independent of the "polling stops after the first re-render" problem. Even with that fixed, backoff still wouldn't apply.
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 94
- Avg merge
- 1h 2m
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MergeFi/frontend
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug testing
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
accessibility bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MergeFi/frontend#835 · 1 comment ·
Maintainers usually reply within 1 day
All issues in MergeFi/frontend
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zapcooking/frontend#946 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
WiliamRosa/cosmos-semantic-platform#40 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
liberation-data/drivine#733 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
makecindy/cindy#10062 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day