Failed to find server action/Cannot read properties of undefined (reading 'workers') #72638
Labels
bug
Issue was opened via the bug report template.
Output (export/standalone)
Related to the the output option in `next.config.js`.
Partial Prerendering (PPR)
Related to Partial Prerendering.
Runtime
Related to Node.js or Edge Runtime with Next.js.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/sweet-dan-qdctsl
To Reproduce
yarn && yarn build
cd apps/foo && yarn start
Current vs. Expected behavior
Current behaviour:
Sometimes when server actions are called they throw a
Failed to find server action/Cannot read properties of undefined (reading 'workers')
error. This is most likely due to Next.js not recognizing which server actions should be included on a page.Expected behaviour:
Server actions run without errors. Not sure how to better define it.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 23.2.0 npm: 10.2.4 Yarn: 4.5.1 pnpm: N/A Relevant Packages: next: 15.0.4-canary.5 eslint-config-next: N/A react: 19.0.0-rc-5c56b873-20241107 react-dom: 19.0.0-rc-5c56b873-20241107 typescript: 5.6.3 Next.js Config: output: standalone
Which area(s) are affected? (Select all that apply)
Output (export/standalone), Partial Prerendering (PPR), Runtime
Which stage(s) are affected? (Select all that apply)
next start (local), Other (Deployed)
Additional context
The reproduction example will work correctly, and it (always) works locally when running our application as well. On our deployment it's another thing though and I've been trying to figure out what's causing it for a few weeks now without any luck. I'm not sure how often it happens, because the app mostly works when I use it, but the logs and Sentry is telling me another story.
The code in the reproduction example works and looks mostly the same as in our application though so it should be a good representation of it. We have a internal package in our monorepo which exports server components and actions. We initiate the actions with some other server actions coming from the app that holds logic not suitable for the internal package. Then we wrap them in additional actions from the app that might do redirection or whatever when everything is done. Finally we pass them down to the server components from the internal package where they're sometimes called from a client component and sometimes directly from a server component.
We deploy this to Kubernetes running multiple containers and we set
generateBuildId
to the SHA for the current commit anddeploymentId
to the deployment ID in our pipeline so it should be consistent between builds and deploys. We're also setting theNEXT_SERVER_ACTIONS_ENCRYPTION_KEY
to avoid any inconsistencies between containers. I've also included a minimal example of ourDockerfile
(we're using a customnode
image though so not sure it runs).Is there some way to debug this? Would it be possible to add a flag to turn off optimization for unused server actions?
The text was updated successfully, but these errors were encountered: