Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
[Bug] Interception routes break on every HMR save in Next.js 16 — "Invalid interception route" error | GoodFirstPicks

[Bug] Interception routes break on every HMR save in Next.js 16 — "Invalid interception route" error

vercel/next.js 3 comments 18d ago
View on GitHub
lowopenScope: clearSkill match: yesNext.jsTypeScriptReact

Why this is a good first issue

The issue clearly identifies a bug in HMR handling of interception routes with a proposed fix.

AI Summary

The issue describes a bug where interception routes accumulate invalid entries on every HMR save, causing errors. The fix involves filtering existing interception routes before pushing new ones. The problem is well-documented with reproduction steps and a clear root cause analysis.

Issue Description

Link to the code that reproduces this issue

https://github.com/aleewains/next-app

To Reproduce

  1. Create a new Next.js 16 project: npx create-next-app@latest
  2. Create the following file structure:
    • app/users/@modal/(.)[id]/page.tsx (intercepting route)
    • app/users/@modal/default.tsx (returns null)
    • app/users/[id]/page.tsx (full page)
    • app/users/layout.tsx (renders {children} and {modal} slots)
    • app/users/page.tsx
  3. Start dev server: npm run dev
  4. Navigate to http://localhost:3000/users
  5. Then click on a cardm it open a modal,
  6. Now, save any file in the project (add a space and save)
  7. Observe the error in the terminal
  8. also oberve interception-route-rewrite-manifest file in .next/server
  9. video link explaining https://drive.google.com/file/d/1PBaVuGAvnZzVYZF5IY4NC_9Oe9fJs6Ez/view

Current vs. Expected behavior

Expected: Interception routes continue working normally after HMR file saves.

Actual: The following error is thrown on every file save:

Error: Invalid interception route: /users/(.)(.)(.)1
Must be in the format /<intercepting route>/(..|...|..)(..)/<intercepted route>

The number of (.) markers increases with each save (1 save = 1 marker, 3 saves = 3 markers), proving entries accumulate. A full dev server restart is required each time to temporarily resolve it.

Root Cause (investigated): In setup-dev-bundler.js, interception routes are pushed into beforeFiles on every HMR update without clearing old entries:

// Runs on EVERY HMR update — never clears!
opts.fsChecker.rewrites.beforeFiles.push(...interceptionRoutes); // BUG

Fix — filter before pushing:

opts.fsChecker.rewrites.beforeFiles = opts.fsChecker.rewrites.beforeFiles
    .filter(r => !_generateinterceptionroutesrewrites.isInterceptionRouteRewrite(r));
opts.fsChecker.rewrites.beforeFiles.push(...interceptionRoutes);

This is a regression — Next.js 15.2.4 does not have this code at all and wo

GitHub Labels

TurbopackParallel & Intercepting Routes

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • regression risk
  • HMR-sensitive
Loading labels...

Details

Points10 pts
Difficultylow
Scopeclear
Skill Matchyes
Test Focusedno