Title: nextjs: build-time instrumentation Turbopack rule runs on every file of instrumented packages · Issue #26675 · getsentry/sentry-javascript · GitHub
Open Graph Title: nextjs: build-time instrumentation Turbopack rule runs on every file of instrumented packages · Issue #26675 · getsentry/sentry-javascript
X Title: nextjs: build-time instrumentation Turbopack rule runs on every file of instrumented packages · Issue #26675 · 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/26675
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"nextjs: build-time instrumentation Turbopack rule runs on every file of instrumented packages","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.15.0\n\n### Framework Version\n\nNext 16.4.6 (Turbopack)\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\nhttps://github.com/vienneraphael/sentry-nextjs-build-instrumentation-repro\n\n```js\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs/config\";\n\nexport default withSentryConfig(\n {},\n {\n silent: true,\n sourcemaps: { disable: true },\n buildTimeInstrumentation: process.env.BUILD_TIME_INSTRUMENTATION !== \"0\",\n }\n);\n```\n\nOne App Router route imports `openai` and `@langchain/core`.\n\n### Steps to Reproduce\n\n1. `npm install && npm run setup`\n2. `BUILD_TIME_INSTRUMENTATION=0 /usr/bin/time -l npm run build`\n3. `rm -rf .next && BUILD_TIME_INSTRUMENTATION=1 /usr/bin/time -l npm run build`\n4. Compare `maximum resident set size` between the two builds (on Linux, use `/usr/bin/time -v` and `Maximum resident set size`)\n5. To count loader calls: `node count-loader-calls.mjs`, then `rm -rf .next && npm run build`, then `node count-loader-calls.mjs restore`\n\n### Expected Result\n\nThe orchestrion loader runs only on files that an instrumentation targets.\n\n### Actual Result\n\nThe loader runs on every JS file of the instrumented packages:\n\n```\nloader ran on 375 files with 68773 bytes of options each\n5 of them are instrumentation targets\n```\n\nThe options include an absolute helper path, so the byte count varies slightly with the install location. The 375 files are 236 in `openai` and 139 in `@langchain/core`. Peak build RSS goes from 941 MiB to 1,151 MiB with build-time instrumentation on, for this one route.\n\n### Additional Context\n\nThis follows #24764. #24792 limited the rule to instrumented packages, and this would narrow it to the instrumented files within them. Per #24792, the loader already skips files the transform never touches, so the set of transformed modules would not change.\n\n`maybeAddOrchestrionRule` matches `*.{js,mjs,cjs}` with `{ path: /node_modules/(?:\u003c62 packages>)/ }`. The instrumentation list names 146 files (`module.name` + `module.filePath`), and 5 of them are present here. Every matched file also receives the full serialized instrumentation list (about 69 KB) as loader `options`. Turbopack currently keeps a copy of a rule's options for every module it matches (https://github.com/vercel/next.js/issues/102105), so the cost grows with the number of files in these packages.\n\nPossible fixes:\n- Build the rule's `path` condition from `module.name/module.filePath`, so only target files match. In this repro that is 5 files instead of 375.\n- Have the loader read the instrumentation list itself instead of receiving it as `options`.\n\nWorkaround: `buildTimeInstrumentation: false`, which also disables these spans.\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>","author":{"url":"https://github.com/vienneraphael","@type":"Person","name":"vienneraphael"},"datePublished":"2026-11-19T23:32:45Z","url":"https://github.com/getsentry/sentry-javascript/issues/26675"}
| 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:bc589103-8126-9b6c-9202-1ed607617165 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E536:2E648F:816625:B0E1B0:6B04486F |
| html-safe-nonce | 9d4b37864b7a98ea79ef097ef4750f4a4d5250aaf7bd5c3f52f93266a631b9b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTM2OjJFNjQ4Rjo4MTY2MjU6QjBFMUIwOjZCMDQ0ODZGIiwidmlzaXRvcl9pZCI6IjgxMzYzMDE3MDcwNjUwNTEyNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8d0d0022add4f9f949a34743897e618d154751e0e4de69637ddf3f6108f3cc2e |
| hovercard-subject-tag | issue:6501227849 |
| 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/26675/issue_layout |
| twitter:image | https://opengraph.githubassets.com/70d7e6338c0dd6268923963e71508f8cefab863ee5cbafde3f16bc9e870d8ffe/getsentry/sentry-javascript/issues/26675 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/70d7e6338c0dd6268923963e71508f8cefab863ee5cbafde3f16bc9e870d8ffe/getsentry/sentry-javascript/issues/26675 |
| 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 | vienneraphael |
| 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