Title: [nextjs] `sourceMappingURL` comment is not stripped from Turbopack worker chunks when `deleteSourcemapsAfterUpload` is enabled · Issue #25874 · getsentry/sentry-javascript · GitHub
Open Graph Title: [nextjs] `sourceMappingURL` comment is not stripped from Turbopack worker chunks when `deleteSourcemapsAfterUpload` is enabled · Issue #25874 · getsentry/sentry-javascript
X Title: [nextjs] `sourceMappingURL` comment is not stripped from Turbopack worker chunks when `deleteSourcemapsAfterUpload` is enabled · Issue #25874 · 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/25874
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[nextjs] `sourceMappingURL` comment is not stripped from Turbopack worker chunks when `deleteSourcemapsAfterUpload` is enabled","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- [ ] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases (using 11.8.0; the relevant code is unchanged on `develop`, see Additional Context)\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.8.0\n\n### Framework Version\n\nNext 16.4.2 (Turbopack production build)\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\n```ts\n// next.config.ts\nimport { withSentryConfig } from '@sentry/nextjs/config'\n\nexport default withSentryConfig(\n {\n output: 'export',\n productionBrowserSourceMaps: true,\n },\n {\n org: '\u003corg>',\n project: '\u003cproject>',\n authToken: process.env.SENTRY_AUTH_TOKEN,\n sourcemaps: {\n deleteSourcemapsAfterUpload: true,\n },\n },\n)\n```\n\nThe app creates a Web Worker with `new Worker(new URL('./worker', import.meta.url))`, so Turbopack emits a worker bootstrap chunk (`static/chunks/turbopack-worker-\u003chash>.js`).\n\n### Steps to Reproduce\n\n1. Use the config above in a Next.js 16 app that creates a Web Worker with `new Worker(new URL(..., import.meta.url))`.\n2. Run `next build` (Turbopack) with `SENTRY_AUTH_TOKEN` set, so that source maps are uploaded.\n3. Inspect the end of `.next/static/chunks/turbopack-worker-\u003chash>.js` (or the copied file in `out/`).\n\n### Expected Result\n\nAll `sourceMappingURL` comments are removed from the client JS after the source maps are uploaded and deleted, as with every other chunk.\n\n### Actual Result\n\nThe worker bootstrap chunk still ends with a `sourceMappingURL` comment that points to a deleted `.map` file:\n\n```js\n;!function(){try{var e=...;e._sentryDebugIds[n]=\"\u003cdebug-id>\",e._sentryDebugIdIdentifier=\"sentry-dbid-\u003cdebug-id>\")}catch(e){}}();\n!function(){ /* Turbopack worker bootstrap */ }();\n\n//# sourceMappingURL=\u003chash>.js.map\n//# debugId=\u003cdebug-id>\n```\n\nAll other chunks are stripped correctly. Without `SENTRY_AUTH_TOKEN`, the upload does not run and the comment is stripped, so the issue only appears in builds that actually upload source maps.\n\n### Additional Context\n\nThis seems to be caused by two steps that run in this order in `handleRunAfterProductionCompile`:\n\n1. Upload: `@sentry/bundler-plugins` calls `sentry sourcemap upload` (`sentry` CLI 0.45.0) without `--no-rewrite`. For JS files that have neither a `//# debugId=` comment nor a debug ID in their source map, the CLI injects a debug ID in place. It prepends the `_sentryDebugIds` snippet and **appends** `\\n//# debugId=\u003cid>\\n` after the existing `sourceMappingURL` comment.\n - https://github.com/getsentry/cli/blob/3567c3c937b5cc06667d5b023bda0b2d3f472c54/packages/cli/src/lib/sourcemap/debug-id.ts#L230\n - Turbopack's native debug IDs (`turbopack.debugIds`) are added to regular chunks, but not to the worker bootstrap chunk, so only this chunk gets injected by the CLI.\n2. Strip: `stripSourceMappingURLComments` uses a regex anchored to the end of the file, so it no longer matches once `//# debugId=` follows the `sourceMappingURL` comment.\n - https://github.com/getsentry/sentry-javascript/blob/90c1ebb9ae6e7521de3e45acb9cc01f506d860bf/packages/nextjs/src/config/handleRunAfterProductionCompile.ts#L98-L100\n - https://github.com/getsentry/sentry-javascript/blob/90c1ebb9ae6e7521de3e45acb9cc01f506d860bf/packages/nextjs/src/config/handleRunAfterProductionCompile.ts#L140\n\nThe relevant code is unchanged on `develop` of sentry-javascript and in `sentry` CLI 0.47.0 (the CLI still appends `//# debugId=` after existing content).\n\nA possible fix is to make the strip regex tolerate trailing `//# debugId=` comments (or remove `sourceMappingURL` comments regardless of position in the trailing comment block).\n","author":{"url":"https://github.com/macchiitaka","@type":"Person","name":"macchiitaka"},"datePublished":"2026-10-29T12:16:46Z","url":"https://github.com/getsentry/sentry-javascript/issues/25874"}
| 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:a4ce3901-aa88-ed82-1949-1f3a2952ed7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBF4:1652C6:69241:90BEB:6B042C0F |
| html-safe-nonce | 2833d1ce7987337cffe3e13f3ba020b33ac743c26537537eacc1ecd48573481f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkY0OjE2NTJDNjo2OTI0MTo5MEJFQjo2QjA0MkMwRiIsInZpc2l0b3JfaWQiOiI0MDMxOTE1NTEzNTYwNTQ1NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a38b2238373a48d92a87b5defad712e924061fcd2bf025a9df4454206884d87f |
| hovercard-subject-tag | issue:6099442279 |
| 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/25874/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b08cda9b2cdcc84a5cd5ef6955a8046cebb23b2b8de6b79cd353f292f3a9868f/getsentry/sentry-javascript/issues/25874 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b08cda9b2cdcc84a5cd5ef6955a8046cebb23b2b8de6b79cd353f292f3a9868f/getsentry/sentry-javascript/issues/25874 |
| 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 | macchiitaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| 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 | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| 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