-
Notifications
You must be signed in to change notification settings - Fork 262
Open
Description
Describe the bug
When using Next.js 15 with Node.js v18.20.3, I encounter an error:
[ Server ] Error: Cannot read properties of undefined (reading 'call')
This happens when I try to export functions from other files that have 'use server' at the top.
- Changing the exported function from an arrow function to a normal function expression resolves the error temporarily.
- However, restarting the server (via
npm run dev) causes the same error to reappear, and I need to reverse the function type (e.g., from normal function expression to arrow function) for it to work again.
This creates a loop where I constantly have to toggle the function type after every server restart to avoid the error. It seems like a bug related to the use of 'use server' or the server's handling of function exports.
Link to the blitz that caused the error
https://stackblitz.com/~/github.com/clickspider/bolt-nextjs-subscription-payments/tree/debug-main-13
Steps to reproduce
- Create a file with a function export, e.g., using an arrow function, and add
'use server'at the top. - Import this function into another file in a Next.js 15 project.
- Start the development server with
npm run devand observe the error:[ Server ] Error: Cannot read properties of undefined (reading 'call') -
- Change the function to a normal function expression (instead of an arrow function).
- The error disappears.
- Restart the development server, and the error reappears.
- Repeat step 4, toggling the function type, and observe the same pattern.
Expected behavior
The exported function should work consistently without toggling between an arrow function and a normal function expression after every server restart.
Parity with Local
- I have run the project in my local machine and I could not reproduce the issue.
Screenshots
Platform
- OS: macOS
- Browser: Chrome
- Version 131.0.6778.109 (Official Build) (arm64)
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels