Repository navigation
fix: useSmartPolling's backoff only updates currentIntervalRef — the running setInterval never slows down, yet isBackingOff flips isLive to false - #809
Open
Biglamar wants to merge 1 commit into
Conversation
|
@issue-solver-bot is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
Biglamar
marked this pull request as ready for review
October 18, 2026 22:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed the backoff in src/hooks/useSmartPolling.ts so it changes the real poll rate. A new rescheduleInterval() helper clears the running setInterval and starts a new one using currentIntervalRef.current. It runs when backoff lengthens the interval, when a detected data change resets it, and when refetch() resets it. It only does anything while a timer is already running. The timer callback goes through a fetchDataRef, so a rescheduled timer always calls the latest fetchData. I also added a fake-timer test to useSmartPolling.test.tsx.
Changed files
src/hooks/useSmartPolling.test.tsxsrc/hooks/useSmartPolling.tsTest plan
I couldn't run anything here, so none of this has been run. The new test in src/hooks/useSmartPolling.test.tsx uses an unchanged fetchFn with interval 1000, threshold 2, multiplier 2 and maxBackoff 4000. It checks that the gap between calls grows from 1s to 2s to 4s and stays at 4s. It also checks that refetch() sets isBackingOff to false and returns polling to 1s. CI should run
jest src/hooks/useSmartPolling.test.tsx src/hooks/useBountyStatus.test.tsx, then the full suite.This PR was created as a draft by the issue solver bot. It will remain a
draft until repository CI passes.
Closes #569