Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Turbopack Error: "Failed to find Server Action" when passing re-exported server actions from RSC to Client Components #78529

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

Open
ryanburns23 opened this issue Apr 25, 2025 · 4 comments
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Server Actions Related to Server Actions. Turbopack Related to Turbopack with Next.js.

Comments

@ryanburns23
Copy link

Link to the code that reproduces this issue

https://github.com/ryanburns23/failed-to-find-server-action

To Reproduce

  1. Start the reproduction project using: next dev --turbopack
  2. Click the button which triggers a server action passed as a prop from a RSC to a client component.
  3. Observe the error message in the terminal: Error: Failed to find Server Action

Current vs. Expected behavior

Current Behavior:
When calling the logAction() server action, a terminal error appears: Error: Failed to find Server Action.

Expected Behavior:
The server action (logAction()) should execute normally without the error message.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:11 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6020
  Available memory (MB): 98304
  Available CPU cores: 12
Binaries:
  Node: 22.13.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.6.2
Relevant Packages:
  next: 15.4.0-canary.9 // Latest available version is detected (15.4.0-canary.9).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Server Actions, Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

  • The reproduction illustrates the issue occurs when a server action is re-exported from another file (lib.ts). Specifically, the current setup in actions.ts looks like this:
"use server";
import { log } from "./lib";
export { log as logAction };
  • Defining logAction() directly within actions.ts (with "use server" at the top) prevents the issue.
  • Importing the server action directly from the logger client component also resolves the issue.
  • The issue does not occur when running without Turbopack (i.e., without the --turbopack flag). If testing without Turbopack, you may need to delete the .next folder first.
@github-actions github-actions bot added Server Actions Related to Server Actions. Turbopack Related to Turbopack with Next.js. labels Apr 25, 2025
@mischnic mischnic added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Apr 25, 2025
@MrJs6781
Copy link

So now I understand this problem in general, but these bugs that have been reported cannot be solved by us users because we do not have access to the core code, and these bugs are just for our awareness?

@ryanburns23
Copy link
Author

So now I understand this problem in general, but these bugs that have been reported cannot be solved by us users because we do not have access to the core code, and these bugs are just for our awareness?

@MrJs6781 Not quite, these issues aren't raised just for awareness. Next.js and Turbopack are open source, so the core code is publicly accessible, meaning anyone (including community members) can propose a fix by creating a pull request. Reporting issues with clear, minimal reproductions helps both the Next.js core team and the community identify and resolve bugs faster. Typically, the core team handles fixes, but contributions from the community are welcome.

@ryanburns23
Copy link
Author

ryanburns23 commented Apr 28, 2025

I did some further testing and was able to pinpoint the release this broke. You can test by pinning the next.js version on the reproduction repo.

14.0.4-canary.43 is the latest working version, anything after that will produce the error.

When looking at 14.0.4-canary.44 there are two PR's that may be related:

  1. side effects optimization: #58972 & turborepo:#6590 (Looks like this is most likely the cause - I did try disabling turbopackTreeShaking but that did not fix the reproduction)
  2. add module tracing for client reference and next/dynamic walking: #59306
    LMK if there is anything I can do to help resolve this.

CC: @sokra

@ryanburns23
Copy link
Author

In case this helps anyone, a temporary workaround is to re-export by defining new variables.

"use server";
import { log } from "./lib";

// This doesn't work due to the bug:
// export { log as logAction };

// This works as a workaround:
export const logAction = log;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Server Actions Related to Server Actions. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants