Title: Reduce @sentry/node startup cost by flattening the published build · Issue #25680 · getsentry/sentry-javascript · GitHub
Open Graph Title: Reduce @sentry/node startup cost by flattening the published build · Issue #25680 · getsentry/sentry-javascript
X Title: Reduce @sentry/node startup cost by flattening the published build · Issue #25680 · getsentry/sentry-javascript
Description: require('@sentry/node') loads 589 CommonJS modules and takes about 92–100 ms on Node 24.21, measured against the local CJS build. NODE_COMPILE_CACHE brought no measurable gain, so the time goes to resolving, reading and evaluating many s...
Open Graph Description: require('@sentry/node') loads 589 CommonJS modules and takes about 92–100 ms on Node 24.21, measured against the local CJS build. NODE_COMPILE_CACHE brought no measurable gain, so the time goes to ...
X Description: require('@sentry/node') loads 589 CommonJS modules and takes about 92–100 ms on Node 24.21, measured against the local CJS build. NODE_COMPILE_CACHE brought no measurable gain, so the time ...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25680
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reduce @sentry/node startup cost by flattening the published build","articleBody":"`require('@sentry/node')` loads 589 CommonJS modules and takes about 92–100 ms on Node 24.21, measured against the local CJS build. `NODE_COMPILE_CACHE` brought no measurable gain, so the time goes to resolving, reading and evaluating many small files rather than compiling them. The packages are built with preserved modules, so each source file becomes its own published file. By module count the largest contributors are `@sentry/server-utils`, `@sentry/core`, `@sentry/server-runtime-injection` (its bundled parser and code generator) and `@opentelemetry/api`.\n\nThis cost lands on every cold start (serverless functions, CLIs, autoscaling containers).\n\n### Proposal\n\nReduce the cost through the build output shape. AGENTS.md rules out lazy loading as a fix, so imports stay static:\n\n- Publish flattened entry files (instead of preserved modules) for `@sentry/node`, `@sentry/server-utils` and `@sentry/server-runtime-injection`, with the same `exports` maps and entry points.\n- Check that nothing which only matters for runtime injection is evaluated on the main entry when it doesn't need to be, using a static restructure rather than lazy `require`.\n- Measure before and after with the count-based gate proposed in the perf issue (modules loaded, import time).\n\n### Risks to check\n\n- Deep imports into `build/` paths\n- `@vercel/nft` / Next.js file tracing\n- The chunk layout that `server-runtime-injection`'s `hook.js` relies on\n- Dual-package hazards between the CJS and ESM builds\n\nRelated: #19885 takes a different approach to the same problem: a separate `@sentry/core/light` entry for lightweight consumers.\n","author":{"url":"https://github.com/mydea","@type":"Person","name":"mydea"},"datePublished":"2026-10-23T07:28:56Z","url":"https://github.com/getsentry/sentry-javascript/issues/25680"}
| 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:5d8b15e1-0931-4480-d77e-8e5d554be70a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE04:5F67C:30455F:414FD5:6B043DB8 |
| html-safe-nonce | 343f340aa3b8710419c040d40e45e871a305ebf231cb82672e77f70d9f660f0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTA0OjVGNjdDOjMwNDU1Rjo0MTRGRDU6NkIwNDNEQjgiLCJ2aXNpdG9yX2lkIjoiMjA0MTU0NDYzMDcxNzM5ODQ1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c79632be7fa3a970d6dfedde56cc5e9dbb4a3811a145564e8807d9fd921f7ea9 |
| hovercard-subject-tag | issue:5993778183 |
| 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/25680/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b59c4a7c2dfae98c52860cde77d25e7add9496ac9ae90aeb945c3f496f6c41d/getsentry/sentry-javascript/issues/25680 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b59c4a7c2dfae98c52860cde77d25e7add9496ac9ae90aeb945c3f496f6c41d/getsentry/sentry-javascript/issues/25680 |
| og:image:alt | require('@sentry/node') loads 589 CommonJS modules and takes about 92–100 ms on Node 24.21, measured against the local CJS build. NODE_COMPILE_CACHE brought no measurable gain, so the time goes to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mydea |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| 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 | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| 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