Bug report
Description / Observed Behavior
Since v2.4.0, useSWRImmutable ignores a refreshInterval passed directly to the hook, not just one inherited from a global <SWRConfig>.
#4208 ("fix: Ensure useSWRImmutable overrides global refreshInterval") added this line to the immutable middleware:
config.refreshInterval = 0
However, middleware runs after the hook-level options have been merged with the context config.
At that point the middleware cannot distinguish a globally configured refreshInterval from one passed as hook options, so it silently disables both. Polling that worked on ≤ 2.3.x stops with no error or warning after upgrading.
Expected Behavior
A refreshInterval passed directly to useSWRImmutable(key, fetcher, { refreshInterval }) should still be honored — only a refreshInterval inherited from a parent <SWRConfig> (the case #4208 was about) should be ignored.
If ignoring the hook-level option is intentional, it would be worth documenting as a breaking change, since it silently changes runtime behavior in a minor release.
Repro Steps / Code Example
import useSWRImmutable from 'swr/immutable'
function Status() {
// On swr 2.3.6: fetches every second.
// On swr >= 2.4.0: fetches exactly once, refreshInterval is discarded.
const { data } = useSWRImmutable('/api/status', fetcher, {
refreshInterval: 1000,
})
return <span>{data?.status}</span>
}
No global <SWRConfig> is involved.
https://codesandbox.io/p/sandbox/thqfwl
Additional Context
SWR version: 2.5.0 (regression introduced in 2.4.0 via #4208; 2.3.6 behaves as expected).
Bug report
Description / Observed Behavior
Since v2.4.0,
useSWRImmutableignores arefreshIntervalpassed directly to the hook, not just one inherited from a global<SWRConfig>.#4208 ("fix: Ensure useSWRImmutable overrides global refreshInterval") added this line to the
immutablemiddleware:However, middleware runs after the hook-level options have been merged with the context config.
At that point the middleware cannot distinguish a globally configured
refreshIntervalfrom one passed as hook options, so it silently disables both. Polling that worked on ≤ 2.3.x stops with no error or warning after upgrading.Expected Behavior
A
refreshIntervalpassed directly touseSWRImmutable(key, fetcher, { refreshInterval })should still be honored — only arefreshIntervalinherited from a parent<SWRConfig>(the case #4208 was about) should be ignored.If ignoring the hook-level option is intentional, it would be worth documenting as a breaking change, since it silently changes runtime behavior in a minor release.
Repro Steps / Code Example
No global
<SWRConfig>is involved.https://codesandbox.io/p/sandbox/thqfwl
Additional Context
SWR version: 2.5.0 (regression introduced in 2.4.0 via #4208; 2.3.6 behaves as expected).