Repository navigation
fix: useSmartPolling stops polling after the first re-render because useBountyStatus passes inline fetchFn/compareFn/onDataChange - #808
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. |
b7b931c to
323d7ea
Compare
323d7ea to
d5f959f
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
In src/hooks/useSmartPolling.ts, fetchFn, compareFn and onDataChange are now held in refs that are updated on every render, so fetchData no longer changes identity when callers pass inline functions. I also removed the
hasInitializedguard from the main polling effect. The effect now recreates the interval whenever it re-runs, including whenenabledgoes from false to true. Before this, the first re-render ran the effect cleanup, which cleared the interval, and nothing recreated it. I added a regression test in src/hooks/useSmartPolling.test.tsx that uses inline callbacks and asserts polling continues past several intervals. I could not run any tests in this session.Changed files
src/hooks/useSmartPolling.test.tsxsrc/hooks/useSmartPolling.tsTest plan
Run
jest src/hooks/useSmartPolling.test.tsx src/hooks/useBountyStatus.test.tsx, plus the ClaimButton and BountyStatus tests. The new test, 'keeps polling across re-renders when callbacks are inline (#568)', asserts fetchFn is called more than twice after three timer advances. The existing enabled-toggle and backoff tests in the same file cover the removal of thehasInitializedguard.This PR was created as a draft by the issue solver bot. It will remain a
draft until repository CI passes.
Closes #568