nextjs - ✅(Solved) Fix Build fails with SWC nullish coalescing operator panic after upgrading to Next.js v16.1.4 [2 pull requests, 9 comments, 8 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#88822Fetched 2026-04-08 02:03:53
View on GitHub
Comments
9
Participants
8
Timeline
29
Reactions
5
Author
Timeline (top)
commented ×9subscribed ×6labeled ×3mentioned ×3

Error Message

  1. Build fails with a panic error related to nullish coalescing operator The build process panics with the following error:

Fix Action

Fixed

PR fix notes

PR #89103: [backport] Upgrade to swc 54 (#88207)

Description (problem / solution / changelog)

Backports #88207 For this issue https://github.com/vercel/next.js/issues/88822

Also includes https://github.com/vercel/next.js/pull/89066/changes/df12b894f9e7d9a15b8b159d260793b8f810ed68 to get CI working

Changed files

  • Cargo.lock (modified, +239/-143)
  • Cargo.toml (modified, +8/-8)
  • crates/next-custom-transforms/tests/loader/issue-30389/output.js (modified, +1/-1)
  • packages/next/taskfile.js (modified, +2/-2)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/exports/invalid-export-parse-error/issues/Parsing ecmascript source code failed-9f1236.txt (renamed, +5/-5)
  • turbopack/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/5c1d0_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_5aaf1327.js (modified, +1/-1)
  • turbopack/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/780ce_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_5aaf1327.js.map (modified, +1/-1)

Code Example

thread 'tokio-runtime-worker' (461588) panicked at /Users/geist/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swc_ecma_transformer-3.2.1/src/es2020/nullish_coalescing.rs:109:31:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'tokio-runtime-worker' (461587) panicked at /Users/geist/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swc_ecma_transformer-3.2.1/src/es2020/nullish_coalescing.rs:109:31:
called `Option::unwrap()` on a `None` value

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 8
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.28.1
Relevant Packages:
  next: 16.1.4 // Latest available version is detected (16.1.4).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

N/A

To Reproduce

  1. Upgrade Next.js to version 16.1.4
  2. Run next build
  3. Build fails with a panic error related to nullish coalescing operator

Current vs. Expected behavior

Current behavior

The build process panics with the following error:

thread 'tokio-runtime-worker' (461588) panicked at /Users/geist/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swc_ecma_transformer-3.2.1/src/es2020/nullish_coalescing.rs:109:31:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'tokio-runtime-worker' (461587) panicked at /Users/geist/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swc_ecma_transformer-3.2.1/src/es2020/nullish_coalescing.rs:109:31:
called `Option::unwrap()` on a `None` value

Multiple similar errors appear in the console after the initial panic.

Expected behavior

The build should complete successfully, properly transforming the nullish coalescing operator (??) without panicking as in v16.1.1.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 8
Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.28.1
Relevant Packages:
  next: 16.1.4 // Latest available version is detected (16.1.4).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

SWC

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

next build (local)

Additional context

Changing the nullish coalescing operator (??) to the logical OR operator (||) in config.ts allows the build to complete, but this is not a proper solution as ?? and || have different semantics.

extent analysis

TL;DR

Downgrade Next.js to version 16.1.1 to avoid the nullish coalescing operator panic error in SWC.

Guidance

  • The issue seems to be related to the SWC transformer in Next.js version 16.1.4, which is causing a panic error when encountering the nullish coalescing operator (??).
  • To verify the issue, try building the project with Next.js version 16.1.4 and check for the panic error.
  • As a temporary workaround, consider downgrading Next.js to version 16.1.1, which is known to work correctly with the nullish coalescing operator.
  • If downgrading is not feasible, try to identify and isolate the specific code that is causing the panic error, and consider using the logical OR operator (||) as a temporary replacement, although this may change the semantics of the code.

Notes

The provided environment information and package versions are helpful in identifying the issue, but without more specific code examples or details about the project, it's difficult to provide a more targeted solution.

Recommendation

Apply workaround: Downgrade Next.js to version 16.1.1, as this version is known to work correctly with the nullish coalescing operator, and the latest version (16.1.4) is causing the panic error.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING