Repository navigation
Add focusThrottleInterval to throttle revalidations on focus - #117
Merged
Merged
Conversation
Within focusThrottleInterval milliseconds after a request or its revalidation, the window regaining focus doesn't revalidate it again, so that refetchOnFocus doesn't send a request every time users switch between tabs quickly. It defaults to 5 seconds, and 0 revalidates on every focus. Revalidations on reconnect and calls of revalidateAll() aren't throttled.
Core bundles 7.75 KB -> 8.75 KB, dist/react/index.mjs 10.75 KB -> 11.75 KB and dist/react/index.js 11.75 KB -> 12.75 KB. The limits fit this and the other PRs opened alongside it (abort signal fix, ETag revalidation, retry jitter and methods, onDownloadProgress, responseType, focusThrottleInterval, initialData and typed OpenAPI endpoints), which add about 1 KB together, so that they can be merged in any order.
size-limit report 📦
|
red-game-dev
approved these changes
Sep 27, 2026
Merged
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.
This pull request adds
focusThrottleInterval, which throttles the revalidations ofrefetchOnFocus, so that users switching between tabs quickly don't trigger a request every time.✨ Features & Improvements
focusThrottleInterval: within this time (in milliseconds) after a request or its revalidation, the window regaining focus doesn't revalidate it again. It defaults to 5 seconds, like in SWR, and0revalidates on every focus. It can be set globally, per endpoint or per request.setEventProvider('focus', ...), e.g. in React Native.revalidateAll('focus')aren't throttled.The window regaining focus within 5 seconds after a request or its revalidation no longer revalidates it. Set
focusThrottleInterval: 0to revalidate on every focus like before.🧪 Tests
0, and no throttling ofrevalidateAll()calls and revalidations on reconnect.focusThrottleInterval: 0.📦 Bundle Size
The core bundles grow by less than 0.1 KB (brotli). The size limits are raised to fit this and the other pull requests opened alongside it, so that they can be merged in any order.
Generated by Claude Code