nextjs - ✅(Solved) Fix jest-worker: "TypeError: Unexpected response from worker: undefined" when using dynamic Routes [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#92836Fetched 2026-04-17 08:21:47
View on GitHub
Comments
2
Participants
2
Timeline
13
Reactions
0
Timeline (top)
mentioned ×4subscribed ×4commented ×2cross-referenced ×1

Error Message

It’s not an error, but when running through a custom server we see a lot of errors of that kind.

Fix Action

Fixed

PR fix notes

PR #92864: Filter Node watch flags from managed workers

Description (problem / solution / changelog)

Fixes #92836.

What changed

This prevents managed child process workers from inheriting Node watch-mode flags such as --watch, --watch-path, and --watch-preserve-output through process.execArgv or NODE_OPTIONS.

In particular, the dev static-paths worker now passes sanitized forkOptions.execArgv, avoiding Node watch-mode messages being sent over the jest-worker IPC channel.

Tests

pnpm testonly packages/next/src/server/lib/utils.test.ts packages/next/src/lib/worker.test.ts

Changed files

  • packages/next/src/cli/next-dev.ts (modified, +8/-6)
  • packages/next/src/lib/worker.test.ts (modified, +27/-0)
  • packages/next/src/lib/worker.ts (modified, +3/-5)
  • packages/next/src/server/dev/next-dev-server.ts (modified, +13/-6)
  • packages/next/src/server/lib/utils.test.ts (modified, +23/-0)
  • packages/next/src/server/lib/utils.ts (modified, +33/-3)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:46 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: 1.22.19
  pnpm: 9.6.0
Relevant Packages:
  next: 16.2.3 // Latest available version is detected (16.2.3).
  eslint-config-next: N/A
  react: 19.2.5
  react-dom: 19.2.5
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/ale-grosselle/bug-nextjs-worker

To Reproduce

  1. npm run start:dev
  2. go to http://localhost:3000/foo/pippo
  3. uncaughtException: TypeError: Unexpected response from worker: undefined at ignore-listed frames

Current vs. Expected behavior

<img width="722" height="522" alt="Image" src="https://github.com/user-attachments/assets/5d682a7e-912f-4f62-a25a-805a23dfb75d" />

It’s not an error, but when running through a custom server we see a lot of errors of that kind. It only happens on dynamic paths.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:46 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: 1.22.19
  pnpm: 9.6.0
Relevant Packages:
  next: 16.2.3 // Latest available version is detected (16.2.3).
  eslint-config-next: N/A
  react: 19.2.5
  react-dom: 19.2.5
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Dynamic Routes

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

next dev (local)

Additional context

It only happens in version 16.2; version 16.1 didn’t have this issue. It only occurs with a custom server — when running with next dev, the problem doesn’t seem to appear.

extent analysis

TL;DR

Downgrade to Next.js version 16.1 to potentially resolve the "Unexpected response from worker: undefined" error on dynamic paths with a custom server.

Guidance

  • Verify that the issue is specific to Next.js version 16.2.3 by testing with version 16.1, as indicated in the additional context.
  • Check the custom server configuration to ensure it is compatible with Next.js version 16.2.3, as the issue does not occur with next dev.
  • Investigate the differences in behavior between next dev and the custom server to identify potential causes of the error.
  • Test dynamic paths with a minimal custom server setup to isolate the issue and determine if it is related to the server configuration or Next.js itself.

Example

No specific code example is provided, as the issue is related to a version-specific problem with Next.js and a custom server.

Notes

The issue seems to be specific to Next.js version 16.2.3 and only occurs with a custom server. Downgrading to version 16.1 may resolve the issue, but it is essential to verify the compatibility of the custom server with the newer version.

Recommendation

Apply workaround: Downgrade to Next.js version 16.1, as it is reported to not have this issue, allowing for temporary resolution while investigating the root cause or waiting for a fix in a future version.

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