r is not a function when wrapping API route with a function and use server #68568
Labels
bug
Issue was opened via the bug report template.
Developer Experience
Issues related to Next.js logs, Error overlay, etc.
Link to the code that reproduces this issue
https://github.com/Floriferous/next-api-bug
To Reproduce
Current vs. Expected behavior
This is a reopening of #67833, as I was still experiencing the bug even after doing what @icyJoseph suggested. The issue is more complex, as it happens because I had 'use server' at the top of the wrapper function's file. I would expect to have some other kind of error, or something that helps in understanding that this pattern is not allowed.
When adding
use server
to a file, it seems to do weird things with your functions, and create really difficult to understand errors and error stacks:I've defined 2 files:
Using these 2 together is somehow not allowed, and the error message does not make much sense.
Here's the error stack:
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 23.5.0: Wed May 1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112 Available memory (MB): 24576 Available CPU cores: 8 Binaries: Node: 20.11.0 npm: 10.7.0 Yarn: 1.21.1 pnpm: N/A Relevant Packages: next: 14.2.5 // Latest available version is detected (14.2.5). eslint-config-next: 14.2.5 react: 18.3.1 react-dom: 18.3.1 typescript: 5.5.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Developer Experience
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: