-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Server actions regression in 14.2.8: “Failed to find Server Action” #69756
Comments
Anecdotally affecting a few other people at the bottom of #58431 |
I just ran into this issue as well. |
Same issue here, was working well with I have an |
I encountered the same issue, which was working fine with 14.2.7. After some investigation, I found a solution by changing the way I export server actions in my index.ts file. Before:
export * from './user/create-user';
export * from './auth/login'; After:
export { createUser } from './user/create-user';
export { authenticate, login } from './auth/login'; The wildcard export (export *) seemed to cause problems with server actions, but explicitly naming the exports resolved the issue. This way, I was able to maintain the imports like this: import { authenticate, login } from '@actions'; without having to reference the full path to the server action. I hope this helps anyone facing a similar problem!
|
Unfortunately, the reproduction I linked doesn't involve wildcard exports, so I don't think every case can be worked around by just avoiding wildcard exports. |
I also ran into this issue, and I could reproduce it consistently by exporting server actions from a barrel file in the same way that @alexOS-dev mentioned. I'm thinking this might be related to this fix? #69178 |
Folks, we had a fix in patch release 14.2.9, please upgrade and let us know if it fixed for you 🙏 |
@huozhi I've upgraded to version 14.2.9, but still receiving this error which seems related to this issue, the server action I'm using is structured as in https://sdk.vercel.ai/examples/next-app/assistants/stream-assistant-responses. When downgrading to v14.2.7, I'm not receiving this error. I'm not sure if this is related to the I've logged a ticket on the Reproduction can be found here: https://github.com/WoetDev/bug-next-ai-sdk |
@huozhi @WoetDev Here is a CodeSandbox reproduction case based on the Save and Restore AI State example. Just enter a message and hit "Send Message" and the error is shown. Downgrading to Nextjs v14.2.7 fixes the issue. |
@WoetDev thanks fore reporting, we'll look into that specific case, as usually the function in A workaround would be having a new file for import { createAI, } from "ai/rsc";
import { submitMessage } from "./actions";
export const AI = createAI({
actions: {
submitMessage,
},
}); This way make sure |
I was having issues, but I tried this solution, and now all the server actions work with version 14.2.9. A bit strange behavior, as with version 14.2.7, everything was working fine with the export * from './file'. Does anyone know the reason why? Or is it just an issue? |
Just ran into this issue too. Had a server action exported (also with the 'use server' at the top of the function) with 'use server' at the top of the file. Reverting to 14.2.7 fixed this issue. The server action was imported into a server component and then passed down to a client component via props. |
We released v14.2.10 with the fix, could you upgrade to the latest version and verify if that fixed for you? 🙏 Thanks |
Server actions work well in 14.2.10 and 14.2.11. |
This error is still present in |
@luskin can you file a new issue with your reproduction? |
Fixed in Next.js |
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 multiple components import from the same
actions.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.page.tsx
importsaction1
action2
from the same file.If
page.tsx
callsaction1
, 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 install
bunx next build && bunx next start
localhost:3000/my-page
Current vs. Expected behavior
Current behavior (
next@canary
andnext@14.2.8
)action1 returned: undefined
i.e. the server action is missing / broken
Expected behavior (
next <= 14.2.7
)action1
action1 returned: {hello: 'world'}
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
next@canary
(141)moduleGraph.getOutgoingConnections()
may be returning incomplete/incorrect information insideconnection.dependency.ids
The text was updated successfully, but these errors were encountered: