Skip to content

Dev: serialize and coalesce route-rescan work #5083

Backlog

Description

@ask-bonk

Next.js Change

Commit: 0de0a33
PR: #102735

What changed

Next.js now serializes development route rescans triggered by file-watcher events. While a scan is active, later events collapse into one trailing scan that reads the latest filesystem state. This prevents older asynchronous scans from interleaving shared route-state mutations or publishing after a newer scan.

Impact on vinext

vinext scans App Router and Pages Router files during development and updates routing/HMR state asynchronously. Its watcher lifecycle must ensure route scans do not overlap and must run one trailing rescan after changes that arrive during an active scan. Otherwise removed routes, route definitions, middleware/proxy matchers, interception rewrites, or type/HMR updates can be restored from stale state.

Acceptance criteria

  • Ensure only one development route scan can mutate or publish route state at a time.
  • Coalesce watcher events received while a scan is running into exactly one trailing scan.
  • Ensure the trailing scan reads the latest filesystem state.
  • Release the serialized runner after both rejected and synchronously thrown scans, without swallowing errors.
  • Add focused coverage for no overlap, trailing-scan coalescing, latest-state publication, and error recovery.
  • Add a development regression for rapid route deletion/restoration or interception changes.

Related

Activity

  1. added
    nextjs-tracking
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    nextjs-tracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions