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
Call any server actions in a v14.1.1-canary.10 or above Next.js app
Current vs. Expected behavior
Current:
The following error is thrown when an arbitrary server action is called.
TypeError: Cannot redefine property: $$id
at Function.defineProperties (<anonymous>)
at t.registerServerReference (/server-actions-build-fail/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:141808)
at i (/server-actions-build-fail/.next/server/app/page.js:1:18906)
at 4426 (/server-actions-build-fail/.next/server/app/page.js:1:16042)
at t (/server-actions-build-fail/.next/server/webpack-runtime.js:1:127)
at 801 (/server-actions-build-fail/.next/server/app/page.js:1:16510)
at Function.t (/server-actions-build-fail/.next/server/webpack-runtime.js:1:127)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async collectGenerateParams (/server-actions-build-fail/node_modules/next/dist/build/utils.js:920:21)
at async /server-actions-build-fail/node_modules/next/dist/build/utils.js:1143:17
Expected: No error prompted
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
Binaries:
Node: 20.10.0
npm: 10.2.3
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 14.1.1-canary.12 // Latest available version is detected (14.1.1-canary.12).
eslint-config-next: 14.1.1-canary.12
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local)
Additional context
This issue starts appearing in v14.1.1-canary.10
Although the reproduction calls the server action directly in an RSC and causes the project to fail to build, the issue is also observed when calling a server action upon user interactions (e.g. on button click), except it will be a runtime error instead.
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
When we apply `createActionProxy` twice to the same value, it currently
errors because we can't override the ID of it.
This PR makes sure that 1) when the value already have an ID defined, we
skip setting it again; 2) all the action IDs are being tracked even for
duplicated ones.
Note that it's technically impossible to "detect" the duplication here
(via static analyzation) and only set it once. For example:
```ts
'use server'
export async function foo () {}
export const bar = a_value_we_dont_know_yet ? foo : async () => {}
```
So, the compiler will always wrap `createActionProxy` for every exported
value and assume they're different Server Actions (hence different IDs).
With this fix, if we find that it's already defined before, we just
return the defined reference as they're strictly identical so the ID
does't matter.
Closes#54655, closes#61183.
Closes NEXT-2264
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
bugIssue was opened via the bug report template.locked
Link to the code that reproduces this issue
https://github.com/mwskwong/server-actions-build-fail
To Reproduce
v14.1.1-canary.10
or above Next.js appCurrent vs. Expected behavior
Current:
The following error is thrown when an arbitrary server action is called.
Expected: No error prompted
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 Binaries: Node: 20.10.0 npm: 10.2.3 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 14.1.1-canary.12 // Latest available version is detected (14.1.1-canary.12). eslint-config-next: 14.1.1-canary.12 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local)
Additional context
v14.1.1-canary.10
Cannot redefine property: $$id
inaction-proxy.ts
#54655The text was updated successfully, but these errors were encountered: