Title: [nextjs] Turbopack: source map upload injects `_sentryDebugIds` into server chunks without shifting sectioned source maps (js_invalid_sourcemap_location) · Issue #26330 · getsentry/sentry-javascript · GitHub
Open Graph Title: [nextjs] Turbopack: source map upload injects `_sentryDebugIds` into server chunks without shifting sectioned source maps (js_invalid_sourcemap_location) · Issue #26330 · getsentry/sentry-javascript
X Title: [nextjs] Turbopack: source map upload injects `_sentryDebugIds` into server chunks without shifting sectioned source maps (js_invalid_sourcemap_location) · Issue #26330 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/26330
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[nextjs] Turbopack: source map upload injects `_sentryDebugIds` into server chunks without shifting sectioned source maps (js_invalid_sourcemap_location)","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/nextjs\n\n### SDK Version\n\n11.12.0\n\n### Framework Version\n\nNext.js 16.4.5 (Turbopack)\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\nMinimal app, official manual setup, Next.js 16.4.5 (Turbopack is the default bundler).\n\n`package.json` dependencies: `next@16.4.5`, `react@19.3.0`, `react-dom@19.3.0`, `@sentry/nextjs@11.12.0` (resolves `@sentry/bundler-plugins@11.12.0`, `sentry@0.49.0`).\n\n`next.config.ts`\n```ts\nimport { withSentryConfig } from \"@sentry/nextjs/config\";\nimport type { NextConfig } from \"next\";\n\nconst nextConfig: NextConfig = {};\n\nexport default withSentryConfig(nextConfig, {\n org: \"example-org\",\n project: \"example-project\",\n authToken: process.env.SENTRY_AUTH_TOKEN,\n silent: !process.env.CI,\n});\n```\n\n`app/api/boom/route.ts`\n```ts\nexport async function GET() {\n throw new Error(\"boom\");\n}\n```\n\n`instrumentation.ts`\n```ts\nimport * as Sentry from \"@sentry/nextjs\";\nexport async function register() {\n if (process.env.NEXT_RUNTIME === \"nodejs\") await import(\"./sentry.server.config\");\n}\nexport const onRequestError = Sentry.captureRequestError;\n```\n\n`sentry.server.config.ts`\n```ts\nimport * as Sentry from \"@sentry/nextjs\";\nSentry.init({ dsn: \"https://public@example.com/1\" });\n```\n\n### Steps to Reproduce\n\n1. Create the app above and run `next build` **without** `SENTRY_AUTH_TOKEN`. Open the server chunk that contains the route (`.next/server/chunks/[root-of-the-server]__*.js`) and its `.map`.\n2. Run `SENTRY_AUTH_TOKEN=\u003cany value> CI=1 next build` (a fake token is enough to reproduce the file change; the upload itself then fails with 401).\n3. Open the same chunk and `.map` again and compare.\n\nWith a real token (Next.js 16.4.5 + Turbopack on Vercel), a server error thrown in a route handler arrives with a minified frame and the processing error `js_invalid_sourcemap_location` (\"Invalid location in sourcemap\").\n\n### Expected Result\n\nThe server chunk keeps lining up with its source map, and server stack frames are symbolicated to `app/api/boom/route.ts`.\n\nEither the upload leaves the chunk alone (Turbopack already wrote a native debug ID: the `//# debugId=` comment and a `_debugIds` snippet on line 1), or, if a `_sentryDebugIds` snippet is inserted, the source map is shifted by the same number of lines.\n\n### Actual Result\n\n| Build | `_sentryDebugIds` snippet in chunk | Line of `throw new Error(\"boom\")` | Source map `sections[0].offset` |\n|---|---|---|---|\n| no token | no | 2 | `{\"line\":1,\"column\":0}` |\n| token set | yes (new line 1) | 3 | `{\"line\":1,\"column\":0}` (unchanged) |\n\nTurbopack emits **index (sectioned) source maps** for server chunks: top-level `sections`, no top-level `mappings`. The injected snippet moves the code down one line, but the map is not shifted, so every server frame points one line off and Sentry reports `js_invalid_sourcemap_location`.\n\nThe unshifted map itself is fine: Node's `module.SourceMap` resolves the original position to the correct file and line.\n\n### Additional Context\n\nWhat I traced in the installed packages:\n\n- `@sentry/nextjs` `handleRunAfterProductionCompile` correctly skips `injectDebugIds()` when `usesNativeDebugIds` is true, then calls `uploadSourcemaps([distDir], { prepareArtifacts: false })`.\n- `@sentry/bundler-plugins` (`core/cli.js`) passes that directory to `sdk.sourcemap.upload(...)` of the `sentry` CLI (0.49.0).\n- In the `sentry` CLI upload path, a file is treated as already injected only if it has a `//# debugId=` comment **and** a `_sentryDebugIds` snippet with the same ID. Turbopack's native snippet uses `_debugIds`, so the CLI injects its own snippet on top. The map is then adjusted only when `typeof map.mappings === \"string\"`, which skips index maps with `sections`.\n- The CLI has a `skipSnippet` option, but `@sentry/nextjs` does not pass it, so there is no user-side setting to avoid this.\n\nSide note: without `next build --turbo` (or `TURBOPACK=1`), `detectActiveBundler()` treats the default Next.js 16 Turbopack build as webpack, `usesNativeDebugIds` is undefined, and `injectDebugIds()` runs: same off-by-one result. Passing `next build --turbo` avoids that step but not the injection during upload.\n\nPossibly related, different symptom (mangled names, frames do resolve): #18248.\n\n### Priority\n\n_No response_","author":{"url":"https://github.com/alpdeka","@type":"Person","name":"alpdeka"},"datePublished":"2026-11-12T22:35:28Z","url":"https://github.com/getsentry/sentry-javascript/issues/26330"}
| 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:4b037c98-98af-173f-652d-4160080af5dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E546:14435D:200DB:2AC95:6B044872 |
| html-safe-nonce | 50d93e9f6668869955b9ba00439148d204321150739d50c8b73760da97ead98a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTQ2OjE0NDM1RDoyMDBEQjoyQUM5NTo2QjA0NDg3MiIsInZpc2l0b3JfaWQiOiIyMDkzMTMwOTkzMjgzMzg1NDU4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 175894b70541518ccf32e6a16d5b3a669f6b3be084e8f9743f2b714511e63237 |
| hovercard-subject-tag | issue:6360393328 |
| 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/26330/issue_layout |
| twitter:image | https://opengraph.githubassets.com/87ff6147a2cbf5eaf1ae27b8959d56176aee8880bf4bdeea5da74fdff79faea2/getsentry/sentry-javascript/issues/26330 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/87ff6147a2cbf5eaf1ae27b8959d56176aee8880bf4bdeea5da74fdff79faea2/getsentry/sentry-javascript/issues/26330 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alpdeka |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| 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 | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| 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