Skip to content

fix: notify all key listeners on revalidation events#4265

Open
pupuking723 wants to merge 1 commit into
vercel:mainfrom
pupuking723:fix/revalidate-all-key-listeners
Open

fix: notify all key listeners on revalidation events#4265
pupuking723 wants to merge 1 commit into
vercel:mainfrom
pupuking723:fix/revalidate-all-key-listeners

Conversation

@pupuking723

Copy link
Copy Markdown

Fixes #2333.

This updates global focus/reconnect revalidation dispatch so every mounted listener for a cache key receives the event instead of only the first registered listener.

Previously, if multiple hooks shared a key and the first registered hook was paused via isPaused(), focus/reconnect revalidation stopped there and active consumers with the same key could not revalidate. Each listener already checks its own config before revalidating, and request deduping still prevents duplicate fetches for active consumers sharing the same key.

Verification:

  • pnpm test -- test/use-swr-focus.test.tsx --runInBand
  • pnpm types:check
  • pnpm exec prettier --check src/_internal/utils/cache.ts test/use-swr-focus.test.tsx
  • pnpm exec eslint src/_internal/utils/cache.ts test/use-swr-focus.test.tsx

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.

Multiple consumers of the same cache key all paused if only one isPaused() evaluates to true

1 participant