-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"use cache" cannot call function from inside closure #72403
Comments
in this case, 'use cache' isn't working in development mode, but it works well when you run 'next build' and 'next start.' It might be helpful if this were mentioned in the documentation as well. |
@TheCodby I don't get that behaviour. If you run
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link to the code that reproduces this issue
https://github.com/romeovs/use-cached-closures-repro
To Reproduce
next dev
There will be the error:
app/page.tsx
to use../api/direct
instead of../api/closure
Current vs. Expected behavior
"use cache"
should work inside functions closures, and should be able to use closed over values. This will help with wrapping third-party clients with a Next.js cache.If that's not possible for some reason, I would like the Next.js compiler to make it clear in the error message and this should be documented somewhere. It would also seriously reduce the usefulness of the
"use cache"
pattern.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:46 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6031 Available memory (MB): 36864 Available CPU cores: 14 Binaries: Node: 20.18.0 npm: 10.8.2 Yarn: 1.22.21 pnpm: 9.12.3 Relevant Packages: next: 15.0.3-canary.7 // Latest available version is detected (15.0.3-canary.7). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: 5.6.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
dynamicIO
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: