Title: Next.js app router: `router.back()`/`router.forward()` navigations are tagged `browser.popstate` under span streaming · Issue #23909 · getsentry/sentry-javascript · GitHub
Open Graph Title: Next.js app router: `router.back()`/`router.forward()` navigations are tagged `browser.popstate` under span streaming · Issue #23909 · getsentry/sentry-javascript
X Title: Next.js app router: `router.back()`/`router.forward()` navigations are tagged `browser.popstate` under span streaming · Issue #23909 · getsentry/sentry-javascript
Description: What With span streaming enabled, a router.back() or router.forward() navigation in the Next.js app router produces a navigation span with navigation.type: 'browser.popstate' instead of router.back / router.forward. Under traceLifecycle:...
Open Graph Description: What With span streaming enabled, a router.back() or router.forward() navigation in the Next.js app router produces a navigation span with navigation.type: 'browser.popstate' instead of router.back...
X Description: What With span streaming enabled, a router.back() or router.forward() navigation in the Next.js app router produces a navigation span with navigation.type: 'browser.popstate' instead of rou...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23909
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Next.js app router: `router.back()`/`router.forward()` navigations are tagged `browser.popstate` under span streaming","articleBody":"## What\n\nWith span streaming enabled, a `router.back()` or `router.forward()` navigation in the Next.js app router produces a navigation span with `navigation.type: 'browser.popstate'` instead of `router.back` / `router.forward`.\n\nUnder `traceLifecycle: 'static'` the same navigations are tagged `router.back` / `router.forward`.\n\n## Evidence\n\nObserved in the `nextjs-app-dir` E2E app (Next 14.2.35, production build) while porting it to span streaming in #23905. The streamed event dump for a full run contains no `router.back`, `router.forward` or `router.traverse` value at all — only `browser.popstate` (6), `router.push` (7) and `router.replace` (2). The corresponding navigation spans:\n\n```\nnavigation /navigation/:param/router-back navigation.type=browser.popstate\nnavigation /navigation/:param/router-push navigation.type=browser.popstate (router.forward() case)\n```\n\nThe transaction-based versions of these two tests pass on `develop` today, so this is specific to streaming.\n\n## Likely mechanism\n\nIn `packages/nextjs/src/client/routing/appRouterRoutingInstrumentation.ts`, `router-patch` mode (which is what Next 14 uses, since it has no `onRouterTransitionStart` hook) starts a navigation span tagged `router.back`/`router.forward` with the placeholder name `INCOMPLETE_APP_ROUTER_INSTRUMENTATION_TRANSACTION_NAME`, because `back()`/`forward()` carry no href.\n\nThe `popstate` listener is then supposed to rename that same span:\n\n```ts\nif (currentRouterPatchingNavigationSpanRef.current?.isRecording()) {\n currentRouterPatchingNavigationSpanRef.current.updateName(spanName);\n // ... does not touch navigation.type\n} else {\n // creates a NEW span tagged 'browser.popstate'\n}\n```\n\nUnder streaming the ref appears to no longer be recording when `popstate` fires, so the `else` branch creates a second span tagged `browser.popstate`, and the original placeholder-named span is filtered out by the `ignoreSpans` entry that matches the placeholder name. The net effect is that the back/forward distinction is lost.\n\n## Impact\n\n`navigation.type` no longer distinguishes back/forward from a plain popstate under streaming, for app router apps in `router-patch` mode.\n\n## Status\n\nThe two affected E2E tests (`Creates a navigation span for \\`router.back()\\`` and `... \\`router.forward()\\``) are skipped in #23905 with a pointer to this issue, rather than having their expectations relaxed.","author":{"url":"https://github.com/chargome","@type":"Person","name":"chargome"},"datePublished":"2026-09-02T09:08:04Z","url":"https://github.com/getsentry/sentry-javascript/issues/23909"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:67a34b9a-2e62-cf8f-b996-57e830185303 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AD4:1B6E1C:2F2CE0:414E53:6B042419 |
| html-safe-nonce | 611da6fd2ed2aecf068a311fab026b5f9ec12d6ba04f2e93e355b3d3c9c918e7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUQ0OjFCNkUxQzoyRjJDRTA6NDE0RTUzOjZCMDQyNDE5IiwidmlzaXRvcl9pZCI6IjUxNTQ1NDI3ODUxOTM1ODM2NDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 84c0d21f954f66e5dbe94dc4618518165537a8773a889a6c7a18fe440a4bd032 |
| hovercard-subject-tag | issue:5321981658 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/23909/issue_layout |
| twitter:image | https://opengraph.githubassets.com/088a15adaef5ece0c2cef1d30166bb7ac13cd7eec7de60aa6f50a797fb413c92/getsentry/sentry-javascript/issues/23909 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/088a15adaef5ece0c2cef1d30166bb7ac13cd7eec7de60aa6f50a797fb413c92/getsentry/sentry-javascript/issues/23909 |
| og:image:alt | What With span streaming enabled, a router.back() or router.forward() navigation in the Next.js app router produces a navigation span with navigation.type: 'browser.popstate' instead of router.back... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chargome |
| hostname | github.com |
| expected-hostname | github.com |
| None | f8d9f404447ab5df341c8a92cf5fc927730ad1321e64ac57656444d2438097f1 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f7edccce04851591ee529948701779ce6819bc53 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width