Closed benjick closed 1 month ago
Hi, thanks for trying the lib. the repository is private. Have you made sure that its not the problem in unstable_cache itself?
Sorry, I made it public now.
I haven't tried verifying with unstable_cache yet, but it's a good idea!
I've updated the repo with an unstable_cache example as well. It works after upgrading next to 14.2.3
Thanks, will test this out
Ive tried the repo and it works well for me?
Just to clarify, did you update next to 14.2.3?
No i didnt, ok now i can see it. Ill try to see what causes this 🤔
I just discovered what causes this. This is because functions that are exported from "use server" will be converted into async functions. This makes the () => ['test-case-value]
part to become async and will failed to get read by memoize
.
I just experimented with it now and I completely understand that its not your fault. But do know that "use server" shouldnt be used to place data fetching function as any function that is exported from that file will become an endpoint.
I will put a warning in the function to better communicate with developers on how they should use their memoize functions.
I just verified that and you are right! Thank you so much for discovering the reason behind this! 🙏
My pattern has been to group both "reads and writes" in a single file based on their purpose, like groups.ts
and putting "use server"
in that file.
Thanks again @alfonsusac!
Hello!
I'm facing an issue where I can't revalidate cached data when upgrading to 14.2. Works fine on 14.1.0.
I've created a reproduction for the issue here: https://github.com/benjick/unstable-cache-error-reproduction