useSmartPolling: toggling `enabled` off leaves isPolling=true, and toggling it back on never restarts polling
Maintainers usually reply within 1 day
@Proxima84-code is already working on this.
Since Oct 6, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start with the useSmartPolling hook and how useBountyStatus forwards enabled to it, focusing on the main effect, the hasInitialized guard, and the cleanup that skips dispatching STOP_POLLING. Pull request #585 is already open against this issue, so check it before writing code. Done means enabled going false sets isPolling to false, going true again restarts polling, and fake-timer tests cover both transitions.
Written by the indexing model from the issue text.
Description
Problem
useSmartPolling accepts enabled, which useBountyStatus forwards, but the main effect doesn't handle it changing:
true → false: the cleanup clears the interval, but deliberately doesn't dispatchSTOP_POLLING("to avoid state updates during unmount"). The body then returns early because!enabled. SoisPollingstaystrueeven though nothing is polling, anduseBountyStatus'sisLivekeeps reporting live.false → true: if the hook started enabled,hasInitialized.currentis alreadytrue, so theif (!hasInitialized.current)block is skipped and polling never resumes. Only a tab hide/show, through thevisibilitychangehandler, brings it back.
The cleanup can't tell a real unmount apart from a dependency change, so the "don't dispatch on unmount" rule also swallows the legitimate "polling stopped" transition.
Expected
enabled=falsestops the timer and setsisPolling=false.enabled=trueagain, after a disable, starts polling immediately.
Suggested fix
Handle enable and disable explicitly:
- use a dedicated effect on
enabledthat starts or stops the timer and dispatches the matching action, - and keep the unmount-only guard in a separate
useEffect(() => () => { isMountedRef.current = false }, []), which is the patternuseClaimRaceuses (#361).
Add tests for disabling and re-enabling with fake timers.
Related: #46, #359, and the separate issue about polling dying after the first re-render. That one shares the hasInitialized root cause but is triggered by callback identity, not enabled.
- 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