Skip to content

Add commit and abort events to router transition instrumentation#95328

Draft
gaojude wants to merge 1 commit into
canaryfrom
router-transition-lifecycle
Draft

Add commit and abort events to router transition instrumentation#95328
gaojude wants to merge 1 commit into
canaryfrom
router-transition-lifecycle

Conversation

@gaojude

@gaojude gaojude commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Extends the experimental client router transition instrumentation (behind experimental.instrumentationClientRouterTransitionEvents) from a start-only hook to a full lifecycle. Every transition emits onRouterTransitionStart and then exactly one of unstable_onRouterTransitionCommit or unstable_onRouterTransitionAbort, all sharing one id.

onRouterTransitionStart now carries a fromTree route descriptor (renderedPathname, canonicalUrl, routeTemplates with positional :N holes and @slot parallel routes, positional params, searchParams) in place of fromRoutes, and prefetchIntent is removed. commit adds the committed toTree and a hit/miss outcomemiss when the page segment had no cached content and rendered a fallback (the head is excluded since it streams non-blocking). abort fires for an in-flight transition superseded before it commits, with cause set to the committing transition's id.

Transitions correlate by their committed FlightRouterState identity via a module-level buffer that drains on each commit, so no id is threaded onto AppRouterState. start is emitted from the dispatcher rather than the reducer, keeping user hooks out of React's render phase where a throwing hook would break error isolation. Covered by the instrumentation-client-hook e2e suite.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Failing test suites

Commit: fd1b112 | About building and testing Next.js

pnpm test-start-experimental-turbo test/production/app-dir/instrumentation-client-dce/instrumentation-client-dce.test.ts (job)

  • instrumentation client router transition events - dead code elimination > when the experimental flag is enabled > keeps the transition event payload in the client bundle (DD)
Expand output

● instrumentation client router transition events - dead code elimination › when the experimental flag is enabled › keeps the transition event payload in the client bundle

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false

  27 |       expect(
  28 |         chunkContents.some((content) => content.includes('fromRoutes'))
> 29 |       ).toBe(true)
     |         ^
  30 |     })
  31 |   })
  32 |

  at Object.toBe (production/app-dir/instrumentation-client-dce/instrumentation-client-dce.test.ts:29:9)

pnpm test-start test/production/app-dir/instrumentation-client-dce/instrumentation-client-dce.test.ts (job)

  • instrumentation client router transition events - dead code elimination > when the experimental flag is enabled > keeps the transition event payload in the client bundle (DD)
Expand output

● instrumentation client router transition events - dead code elimination › when the experimental flag is enabled › keeps the transition event payload in the client bundle

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false

  27 |       expect(
  28 |         chunkContents.some((content) => content.includes('fromRoutes'))
> 29 |       ).toBe(true)
     |         ^
  30 |     })
  31 |   })
  32 |

  at Object.toBe (production/app-dir/instrumentation-client-dce/instrumentation-client-dce.test.ts:29:9)

pnpm test-start-turbo test/production/app-dir/instrumentation-client-dce/instrumentation-client-dce.test.ts (turbopack) (job)

  • instrumentation client router transition events - dead code elimination > when the experimental flag is enabled > keeps the transition event payload in the client bundle (DD)
Expand output

● instrumentation client router transition events - dead code elimination › when the experimental flag is enabled › keeps the transition event payload in the client bundle

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false

  27 |       expect(
  28 |         chunkContents.some((content) => content.includes('fromRoutes'))
> 29 |       ).toBe(true)
     |         ^
  30 |     })
  31 |   })
  32 |

  at Object.toBe (production/app-dir/instrumentation-client-dce/instrumentation-client-dce.test.ts:29:9)
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Stats cancelled

Commit: fd1b112
View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant