You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When multiple components import from the sameactions.ts file, server actions are missing/broken in the final build.
As seen in the attached repository, the structure I found which reliably reproduces this issue is as follows:
actions.ts (marked with 'use server') exports two server actions.
a page.tsx imports action1
this page also renders a child component, which imports action2 from the same file.
If page.tsx calls action1, the action will return undefined (instead of its real return value) and a “failed to find Server Action” error will appear in the server console:
Error: Failed to find Server Action "84eb9c473d392e3d69c580b53ac4d200bdc426c8". This request might be from an older or newer deployment. Original error: Cannot read properties of undefined (reading 'workers')
...
i.e., all of the server actions that are imported from actions.ts get hooked up properly.
you can see this behavior by downgrading next to 14.2.7 within the included repro repository.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.1.0: Fri Aug 16 19:18:30 PDT 2024; root:xnu-11215.40.42~4/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 10
Binaries:
Node: 22.7.0
npm: 10.8.2
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
next: 14.2.8 // Latest available version is detected (14.2.8).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 5.5.4
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Server actions, runtime, vercel deployments, app router
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Vercel (Deployed)
Additional context
This error also exists with the current next@canary (141)
I made the repro using 14.2.8 to show that the current “stable” version includes this regression, but you can change the package versions to observe that canary is broken but 14.2.7 is not.
This regression in server actions is affecting our production app on Vercel.
There are no issues in the dev server, only after a production build.
Based on debugging the webpack plugin, it seems like webpack’s own moduleGraph.getOutgoingConnections() may be returning incomplete/incorrect information inside connection.dependency.ids
When multiple components import from the same
actions.tsfile, server actions are missing/broken in the final build.As seen in the attached repository, the structure I found which reliably reproduces this issue is as follows:
actions.ts(marked with 'use server') exports two server actions.page.tsximportsaction1action2from the same file.If
page.tsxcallsaction1, the action will return undefined (instead of its real return value) and a “failed to find Server Action” error will appear in the server console:Link to the code that reproduces this issue
https://github.com/controversial/next-server-actions-regression-repro
To Reproduce
Clone the included repository, then
bun installbunx next build && bunx next startlocalhost:3000/my-pageCurrent vs. Expected behavior
Current behavior (
next@canaryandnext@14.2.8)action1 returned: undefinedi.e. the server action is missing / broken
Expected behavior (
next <= 14.2.7)action1action1 returned: {hello: 'world'}i.e., all of the server actions that are imported from
actions.tsget hooked up properly.you can see this behavior by downgrading next to 14.2.7 within the included repro repository.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.1.0: Fri Aug 16 19:18:30 PDT 2024; root:xnu-11215.40.42~4/RELEASE_ARM64_T6000 Available memory (MB): 16384 Available CPU cores: 10 Binaries: Node: 22.7.0 npm: 10.8.2 Yarn: 1.22.22 pnpm: N/A Relevant Packages: next: 14.2.8 // Latest available version is detected (14.2.8). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: 5.5.4 Next.js Config: output: N/AWhich area(s) are affected? (Select all that apply)
Server actions, runtime, vercel deployments, app router
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Vercel (Deployed)
Additional context
next@canary(141)moduleGraph.getOutgoingConnections()may be returning incomplete/incorrect information insideconnection.dependency.ids