Skip to content

[Turbopack] Dead-code elimination drops code after a switch, Server Action returns undefined in production #95257

Description

@albert4719

Link to the code that reproduces this issue

https://github.com/albert4719/turbopack-deadcode-repro

To Reproduce

  1. npm install
  2. npm run build
  3. grep the compiled action chunk in .next/server/chunks/ssr — the code after the switch is gone

Current vs. Expected behavior

A server action with a switch (one empty case + break, and default returning the same value as another case) loses all code after the switch in next build. It returns undefined for the empty case. Works fine in next dev. Details +
de-minified output in the repo README.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 65179
  Available CPU cores: 32
Binaries:
  Node: 26.2.0
  npm: 11.13.0
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.2.9 // Latest available version is detected (16.2.9).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

Other (Deployed), next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SWCRelated to minification/transpilation in Next.js.TurbopackRelated to Turbopack with Next.js.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions