Skip to content

fix(hooks): reschedule active timer when polling backoff applies (#569) - #581

Open
PINYOPATTANAWASANPORN wants to merge 2 commits into
MergeFi:mainfrom
PINYOPATTANAWASANPORN:fix-usesmartpolling-backoff-reschedule-569
Open

PINYOPATTANAWASANPORN wants to merge 2 commits into
MergeFi:mainfrom
PINYOPATTANAWASANPORN:fix-usesmartpolling-backoff-reschedule-569

Conversation

@PINYOPATTANAWASANPORN

Copy link
Copy Markdown

Summary of Changes

  • Updated useSmartPolling (src/hooks/useSmartPolling.ts) to immediately reschedule the active setInterval timer when backoff calculation increases currentIntervalRef.current or when a data change / refetch() resets it back to base interval.
  • Added fake-timer unit test in src/hooks/useSmartPolling.test.ts verifying that setInterval is rescheduled and delay between poll requests expands when backing off.

Root Cause / Technical Context

Previously, updating currentIntervalRef.current on backoff threshold reached had no effect on the running setInterval timer because setInterval captures its delay duration when created. As a result, polling continued at the base frequency even though isBackingOff reported true.

Verification & Testing

  • Executed Jest test runner locally with Exit Code 0:
$ npx jest src/hooks/useSmartPolling.test.ts --coverage=false
# PASS src/hooks/useSmartPolling.test.ts
# Test Suites: 1 passed, 1 total
# Tests:       4 passed, 4 total

@vercel

vercel Bot commented Oct 4, 2026

Copy link
Copy Markdown

@PINYOPATTANAWASANPORN is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant