nextjs - ✅(Solved) Fix [Bug]: `manifest.ts` breaks `HMR` in Next.js 16.2 [2 pull requests, 11 comments, 7 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#91981Fetched 2026-04-08 02:01:56
View on GitHub
Comments
11
Participants
7
Timeline
36
Reactions
6
Timeline (top)
commented ×11subscribed ×8mentioned ×6referenced ×5

Fix Action

Fixed

PR fix notes

PR #231: chore: bump next to 16.2.1

Description (problem / solution / changelog)

Updates all next related packages to 16.2.1. Deletes the manifest.ts file as it causes a regression in HMR (see https://github.com/vercel/next.js/issues/91981), and was not needed anymore in our project regardless.

Changed files

  • app/manifest.ts (removed, +0/-26)
  • bun.lock (modified, +15/-15)
  • next.config.ts (modified, +2/-1)
  • package.json (modified, +3/-3)

PR #92034: Turbopack: exclude metadata routes from server HMR

Description (problem / solution / changelog)

What?

Metadata routes (manifest.ts, robots.ts, sitemap.ts, icon.tsx, apple-icon.tsx, etc.) were not being hot-reloaded in Turbopack dev mode — changes to those files would not be reflected on subsequent requests until a full server restart.

Why?

PR #91466 extended usesServerHmr = true in clearRequireCache() (in hot-reloader-turbopack.ts) from app-page entries only to all app-type entries (pages + route handlers). The motivation was correct: regular route handlers like app/api/hello/route.ts use Turbopack's in-place module update model and benefit from server HMR.

However, metadata routes (/manifest.webmanifest/route, /robots.txt/route, etc.) are also app-type entries but they are not suitable for in-place server HMR. When usesServerHmr = true for a metadata route, clearRequireCache() skips two critical invalidation steps:

  1. Deleting the compiled chunk from require.cache
  2. Calling __next__clear_chunk_cache__()

Without those steps, the old module stays in-memory and all subsequent requests to /manifest.webmanifest (etc.) return the stale content.

How?

Added an !isMetadataRoute(entryPage) guard to the usesServerHmr expression in clearRequireCache(). This restores full cache invalidation for metadata routes on every rebuild while leaving regular route handler server HMR (added in #91466) intact.

// Before
const usesServerHmr =
  serverFastRefresh &&
  entryType === 'app' &&
  writtenEndpoint.type !== 'edge'

// After
const usesServerHmr =
  serverFastRefresh &&
  entryType === 'app' &&
  writtenEndpoint.type !== 'edge' &&
  !isMetadataRoute(entryPage)   // ← metadata routes always clear the cache

isMetadataRoute('/manifest.webmanifest/route')true (excluded from server HMR)
isMetadataRoute('/api/hello/route')false (keeps server HMR, no regression)

Also added a regression test: metadata route hmr > reflects manifest.ts changes on fetch/refresh in the server-hmr test suite, with a manifest.ts fixture that starts at name: 'Version 0'. The test patches the file and asserts the updated JSON is returned on the next fetch.

Fixes #91981

Changed files

  • packages/next/src/server/dev/hot-reloader-turbopack.ts (modified, +14/-7)
  • test/development/app-dir/server-hmr/app/manifest.ts (added, +10/-0)
  • test/development/app-dir/server-hmr/server-hmr.test.ts (modified, +20/-0)

Code Example

Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:09 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.1 // Latest available version is detected (16.2.1).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  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/abhishekmardiya/hmr-cache-breakage-reproduction.git

To Reproduce

Using a manifest.ts file in Next.js 16.2 causes Hot Module Replacement (HMR) to stop working correctly.

After making code changes:

  • HMR is not triggered
  • UI does not update
  • Even a hard reload (Cmd + Shift + R) does not reflect the latest changes

The only way to see updates is by deleting the .next build folder, after which the changes appear correctly.


Steps to Reproduce

  1. Create a Next.js app using version 16.2
  2. Add a manifest.ts file (App Router setup)
  3. Start the development server (next dev)
  4. Make any UI or code change

Current vs. Expected behavior

Expected Behavior

  • HMR should trigger automatically
  • UI should reflect the latest changes instantly
  • Hard reload should always fetch the latest code

Current Behavior

  • No HMR updates occur
  • UI remains stale even after hard reload
  • Changes only appear after deleting .next and restarting

Provide environment information

Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:09 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.1 // Latest available version is detected (16.2.1).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Not sure

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

next dev (local)

Additional context

This issue did not occur before Next.js 16.2

  • Removing manifest.ts restores normal HMR behavior
  • Tested with the latest canary version (16.2.1-canary.10) as well — the issue still persists

@wbinnssmith

extent analysis

TL;DR

The most likely fix is to remove or rename the manifest.ts file, as its presence seems to be causing the Hot Module Replacement (HMR) issue in Next.js 16.2.

Guidance

  • Verify that removing the manifest.ts file resolves the HMR issue, as mentioned in the additional context.
  • Try renaming the manifest.ts file to a different name to see if the issue is specific to the file name or its presence.
  • Check the Next.js documentation for any known issues or changes related to HMR and the manifest.ts file in version 16.2.
  • If the issue persists, try downgrading to a previous version of Next.js to see if the issue is specific to version 16.2.

Example

No code snippet is provided as the issue seems to be related to the presence of a specific file rather than a code-specific problem.

Notes

The issue seems to be specific to Next.js version 16.2 and the presence of a manifest.ts file. The fact that removing the file resolves the issue suggests that it might be a bug or an incompatibility in this specific version.

Recommendation

Apply workaround: Remove or rename the manifest.ts file, as it seems to be the most straightforward solution to resolve the HMR issue in Next.js 16.2. This workaround is recommended because it has been verified to work in the provided additional context.

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

nextjs - ✅(Solved) Fix [Bug]: `manifest.ts` breaks `HMR` in Next.js 16.2 [2 pull requests, 11 comments, 7 participants]