You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing requests to the same endpoint/cache key within the dedupeInterval and i don't think this is the expected behaviour?
In my code example posted below, you can see that 2 mounted react components are using the same custom hook to fetch a client ip.
The custom hook is using swr to fetch the ip.
The component registers an interval to simulate "same time" network requests to the same swr cache key.
Expected Behavior
I would expect to only see 1 request, if two components are using the same swr key while calling mutate within the dedupeInterval time span.
Related? #1786 (comment)
I'm afraid this works as designed. How about not using mutate but instead just 2 components rendering the same key? Will it duplicate?
It is related, but i am just not understanding why this might be the intended behavior. If code executes X mutates on the same key (while revalidate is true) for whatever reason there is no use case in my opinion why SWR should not deduplicate this. In my opinion mutates have to be queued or paused within the deduplication time span while one mutate is refreshing the cache with a request. After the request resolves, the other mutates are reading the cache. Obviously SWR is not doing this.... Is this a design flaw in SWR or are we just expecting to much from the library? What are your thoughts?
Bug report
Description / Observed Behavior
I am experiencing requests to the same endpoint/cache key within the dedupeInterval and i don't think this is the expected behaviour?
In my code example posted below, you can see that 2 mounted react components are using the same custom hook to fetch a client ip.
The custom hook is using swr to fetch the ip.
The component registers an interval to simulate "same time" network requests to the same swr cache key.
Expected Behavior
I would expect to only see 1 request, if two components are using the same swr key while calling mutate within the
dedupeInterval
time span.Repro Steps / Code Example
I made an example with my described behaviour here: CodeSandbox SWR Dedupe Example
Additional Context
SWR version:
2.2.5
but also seeing this in1.3.0
The text was updated successfully, but these errors were encountered: