Link to the code that reproduces this issue
https://github.com/Djangologie/turbopack-dynamic-stale-chunk-repro
To Reproduce
npm install && npm run dev (Turbopack)
- Open http://localhost:3000, click "Seed 12 items" — cards render with
[CATEGORY] prefix
- Edit
src/lib/format-utils.ts: change [${cat.toUpperCase()}] to >> ${cat.toUpperCase()} <<
- Save the file
Expected: HMR updates the cards to show the new format.
Actual: One of:
- Cards still show old format
[REACT] (stale chunk — hash unchanged)
- Crash:
TypeError: formatCategory is not a function (module factory evicted but chunk not re-linked)
- Crash:
Error: Module factory is not available. It might have been deleted in an HMR update.
The stale chunk persists across hard refresh, rm -rf .next + server restart, and even full node_modules reinstall. Only next build (Webpack) resolves it.
Additional context
This compounds severely with persisted Zustand stores (see src/stores/item-store.ts):
- First visit: store empty → SSR and client match → no issue
- User seeds items → persisted to localStorage
- Page reload: server renders 0 items, client hydrates with 12 items from localStorage
- Structural hydration mismatch triggers React 19 error recovery
- Combined with stale dynamic chunk, recovery produces corrupted DOM:
NaN of NaN pagination, missing CSS classes, broken refs
Workaround: Replace next/dynamic with a static import — confirms the issue is specific to the lazy chunk path in Turbopack.
- const ItemCard = dynamic(() => import("./ItemCard"), { ssr: false })
+ import ItemCard from "./ItemCard"
next build + next start works correctly in all cases.
Current vs. Expected behavior
Current: next/dynamic chunks in Turbopack retain stale module references after source edits. The chunk hash does not update, so browsers serve cached stale code indefinitely.
Expected: Editing a module imported by a dynamically-loaded component should invalidate the lazy chunk and generate a new hash, just like Webpack does in production builds.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.6.0
Available memory (MB): 65536
Available CPU cores: 12
Binaries:
Node: 22.14.0
npm: 10.9.2
Yarn: N/A
pnpm: 10.5.2
Relevant Packages:
next: 16.1.6
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.8.3
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)
next dev (local)
Additional context
This was originally filed as #93292 and closed by the bot for missing a reproduction link. This is the re-filed version with a complete minimal reproduction.
Link to the code that reproduces this issue
https://github.com/Djangologie/turbopack-dynamic-stale-chunk-repro
To Reproduce
npm install && npm run dev(Turbopack)[CATEGORY]prefixsrc/lib/format-utils.ts: change[${cat.toUpperCase()}]to>> ${cat.toUpperCase()} <<Expected: HMR updates the cards to show the new format.
Actual: One of:
[REACT](stale chunk — hash unchanged)TypeError: formatCategory is not a function(module factory evicted but chunk not re-linked)Error: Module factory is not available. It might have been deleted in an HMR update.The stale chunk persists across hard refresh,
rm -rf .next+ server restart, and even fullnode_modulesreinstall. Onlynext build(Webpack) resolves it.Additional context
This compounds severely with persisted Zustand stores (see
src/stores/item-store.ts):NaN of NaNpagination, missing CSS classes, broken refsWorkaround: Replace
next/dynamicwith a static import — confirms the issue is specific to the lazy chunk path in Turbopack.next build+next startworks correctly in all cases.Current vs. Expected behavior
Current:
next/dynamicchunks in Turbopack retain stale module references after source edits. The chunk hash does not update, so browsers serve cached stale code indefinitely.Expected: Editing a module imported by a dynamically-loaded component should invalidate the lazy chunk and generate a new hash, just like Webpack does in production builds.
Provide environment information
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
This was originally filed as #93292 and closed by the bot for missing a reproduction link. This is the re-filed version with a complete minimal reproduction.