Repository navigation
fix: useSmartPolling's backoff only updates currentIntervalRef — the running setInterval never slows down, yet isBackingOff flips isLive to false - #809
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. |
7ec8205 to
c55e62e
Compare
c55e62e to
f2d88cc
Compare
|
Warning Possible malicious code: please review before merging. An automated security scan flagged files in this pull request that appear to contain malicious code. Code like this can run automatically when a project is opened in an editor or its dependencies are installed, so it could compromise the machine of anyone who checks out this branch. Automated scans can be wrong, so this may be a false positive. Maintainers: please review the flagged files carefully before merging, on GitHub in your browser rather than by checking out the branch. The malicious part is often hidden far off to the right of an ordinary-looking line, so scroll sideways through each file. @Biglamar: this pull request adds or changes these files, possibly without your knowledge. Malware like this spreads by adding itself to repositories on machines it has infected, so your machine might be compromised. Please undo these changes in this pull request, and don't open or run other projects on that machine until you've checked it. Flagged files at commit Only merge once you're confident these files are safe. ℹ️ Posted automatically by Drips Wave. Questions? Contact support@drips.network. |
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