Skip to content

Next.js 15 - 'Cannot read properties of undefined (reading 'call')' Error When Exporting Functions with 'use server' Directive #1665

@clickspider

Description

@clickspider

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

  1. Create a file with a function export, e.g., using an arrow function, and add 'use server' at the top.
  2. Import this function into another file in a Next.js 15 project.
  3. Start the development server with npm run dev and observe the error: [ Server ] Error: Cannot read properties of undefined (reading 'call')
    1. Change the function to a normal function expression (instead of an arrow function).
  4. The error disappears.
  5. Restart the development server, and the error reappears.
  6. 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

Screenshots

image

Platform

  • OS: macOS
  • Browser: Chrome
  • Version 131.0.6778.109 (Official Build) (arm64)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions