Closed katywings closed 4 weeks ago
Further discussion about this issue: https://discord.com/channels/722131463138705510/910635844119982080/1267045977760469124
We noticed that the bug can even occur without createAsync!
Yeah the issue is with lazy components and interrupted hydration. It thinks it is still hydrating the initial page load and it loads the data originally fetched from the server instead of refetching.
Describe the bug
When an existing
createAsync
call gets updated because of navigation, e.g. if its part of a CatchAll route, there is a somewhat random chance (probably based on timing) that thecache
will return the results from the previous call even if the parameters differ. The example below makes it hopefully more clear 😅, you navigate to/about
, but for some reason the cache function sometimes just returns/
.Your Example Website or App
https://stackblitz.com/edit/github-xgtjzp?file=src%2Fcomponents%2FTest.tsx
Steps to Reproduce the Bug or Issue
cache
,use server
and 1 parameter, that just returns the parametercreateAsync
effect that calls the data function with e.g.location.pathname
, output the result in the jsxExpected behavior
The
cache
d function should always run with the newest arguments after hydration. For the example that means: when I navigate to/about
I expect the cache function to be consistently called with/about
Screenshots or Videos
https://github.com/user-attachments/assets/62c15667-eb17-4717-bb80-0fe4d296a8a5
Platform
Additional context
Workaround: In the
createAsync
call, during the first rerun after hydration, runrevalidate
on thecache