Skip to content
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

Failed to find server action/Cannot read properties of undefined (reading 'workers') #72638

Open
kevva opened this issue Nov 12, 2024 · 0 comments
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.

Comments

@kevva
Copy link
Contributor

kevva commented Nov 12, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/sweet-dan-qdctsl

To Reproduce

  1. Run yarn && yarn build
  2. Run cd apps/foo && yarn start
  3. Submit the form

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.

image

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 and deploymentId to the deployment ID in our pipeline so it should be consistent between builds and deploys. We're also setting the NEXT_SERVER_ACTIONS_ENCRYPTION_KEY to avoid any inconsistencies between containers. I've also included a minimal example of our Dockerfile (we're using a custom node 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?

@kevva kevva added the bug Issue was opened via the bug report template. label Nov 12, 2024
@github-actions github-actions bot added 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. labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant