Skip to content

fix(immutable): honor hook-level refreshInterval in useSWRImmutable (#4322) - #4333

Open
vaibhavmashal wants to merge 1 commit into
vercel:mainfrom
vaibhavmashal:fix/swr-immutable-hook-refresh-interval
Open

fix(immutable): honor hook-level refreshInterval in useSWRImmutable (#4322)#4333
vaibhavmashal wants to merge 1 commit into
vercel:mainfrom
vaibhavmashal:fix/swr-immutable-hook-refresh-interval

Conversation

@vaibhavmashal

Copy link
Copy Markdown

Summary

In #4208, \immutable\ middleware was updated to set \config.refreshInterval = 0\ to prevent inheriting global \SWRConfig\
efreshInterval. However, because this was unconditionally executed inside the middleware, it ignored explicit hook-level
efreshInterval\ options passed directly to \useSWRImmutable\ (e.g. \useSWRImmutable(key, fetcher, { refreshInterval: 100 })).

Changes

  • Removed unconditional \config.refreshInterval = 0\ from the \immutable\ middleware in \src/immutable/index.ts.
  • Defined \useSWRImmutable\ with default
    efreshInterval: 0\ in \hookConfig\ ({ refreshInterval: 0, ...config, use: (config.use || []).concat(immutable) }) so that global config polling is ignored while explicit hook options are preserved.
  • Added a unit test in \ est/use-swr-immutable.test.tsx\ verifying hook-level
    efreshInterval\ revalidations.

Closes #4322

Copilot AI lite review requested due to automatic review settings September 10, 2026 16:57
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

@vaibhavmashal is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

useSWRImmutable ignores hook-level refreshInterval since 2.4.0 (regression of #4208)

2 participants