-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Error: Cannot redefine property: $$id
in action-proxy.ts
#54655
Comments
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate. Why was this issue marked with the
|
In case anything short of a minimal repo helps: I also see this on 13.4.19 but not on 13.4.18. While it seems unlikely to be the cause, I am on MacOS like the OP. I'm using app router. |
Also seeing this on 13.4.19 - working on 13.4.18. On Ubuntu via WSL. |
Seeing it on 13.5 |
I don't know if it helps but: I had the same error because i was exporting the server action wrong. /src/app/page.tsx
/src/app/my-server-action.ts
Then I realized that I was exporting the server action twice. 1x where I define the function and 1x below as default. As soon as I only do 1 of the two and adjust the import in the tsx page accordingly, it also works on next 13.5.4 |
I was putting together a reproduction and eventually reached the same realisation as rawi96 - if you have a file with the I've removed all instances of double exporting and am happily building on 13.5. "use server";
export const ProblematicComponent = () => {
return <div>I am breaking the build on 13.5+ as I am exported twice</div>;
}
export default ProblematicComponent;
^^^^^^^ remove me Reproduction is here: |
@JoshuaHull Nice, this really was a problem, I made the modification and it worked. |
Nice! This solves it for me. Odd but working. Thanks! |
I am using the latest version of nextjs with the ap14p router. The problem in my case was a file in my source code which had the "use server" declarative, which was exporting a named export and a default export of the same variable. "use server"
export const SelectCompany = ()=> <div></div>
export default SelectCompany The solution was to either use Anyway, it's a bug. But that's one work-around which may help someone to survive during development. |
D'oh! Thanks for this. Turns out I had two export statements; one in the function declaration, and one at the end of the file. So, in effect, the server action was being redundantly initialized. |
Thank you all! That helped. Here is another case: Wrong: export const ping = some_fn Correct: export const ping = async () => await some_fn() |
I am getting a similar error after upgrading from v14.1.1-canary.9 to v14.1.1-canary.10
|
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
If anyone is using NX framework, here is another way this issue can happen:
Solution: remove |
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
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 Binaries: Node: 18.16.1 npm: 9.8.0 Yarn: 1.22.19 pnpm: 8.6.10 Relevant Packages: next: 13.4.19 eslint-config-next: 13.4.19 react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App Router
Link to the code that reproduces this issue or a replay of the bug
WIP
To Reproduce
WIp
Describe the Bug
Cannot build the action w/ the server proxy
Expected Behavior
Builds without bug
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: