Skip to content

feat: Remove support for initialising via --require#22513

Merged
timfish merged 1 commit into
developfrom
timfish/feat/no-longer-support---require
Jul 23, 2026
Merged

feat: Remove support for initialising via --require#22513
timfish merged 1 commit into
developfrom
timfish/feat/no-longer-support---require

Conversation

@timfish

@timfish timfish commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Initialising via --require results in the SDK being loaded and initialised in Node's ESM loader thread 🤯

This causes numerous issues:

The last straw way failing to require(esm). This stops us from using any import/require chain that results in CJS requiring ESM. It's part of the reason /server-utils/src/orchestrion/runtime/register.ts needed to do lazy loading.

Since it's so problematic and --import supports loading ESM or CJS everywhere, we should remove support and warn users!

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.78 kB - -
@sentry/browser - with treeshaking flags 26.22 kB - -
@sentry/browser (incl. Tracing) 46.61 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.42 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.41 kB - -
@sentry/browser (incl. Tracing, Replay) 85.85 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.58 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.24 kB - -
@sentry/browser (incl. Feedback) 44.97 kB - -
@sentry/browser (incl. sendFeedback) 32.58 kB - -
@sentry/browser (incl. FeedbackAsync) 37.64 kB - -
@sentry/browser (incl. Metrics) 28.86 kB - -
@sentry/browser (incl. Logs) 29.09 kB - -
@sentry/browser (incl. Metrics & Logs) 29.79 kB - -
@sentry/react 29.57 kB - -
@sentry/react (incl. Tracing) 48.89 kB - -
@sentry/vue 33.21 kB - -
@sentry/vue (incl. Tracing) 48.58 kB - -
@sentry/svelte 27.8 kB - -
CDN Bundle 30.12 kB - -
CDN Bundle (incl. Tracing) 48.5 kB - -
CDN Bundle (incl. Logs, Metrics) 31.7 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.8 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.96 kB - -
CDN Bundle (incl. Tracing, Replay) 86.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.82 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.08 kB - -
CDN Bundle - uncompressed 89.75 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.63 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.47 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.61 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.23 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.87 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.83 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.57 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.53 kB - -
@sentry/nextjs (client) 51.4 kB - -
@sentry/sveltekit (client) 47.03 kB - -
@sentry/core/server 80.14 kB - -
@sentry/core/browser 51.99 kB - -
@sentry/node 124.59 kB +0.26% +320 B 🔺
@sentry/node (incl. diagnostics channel injection) 150.03 kB +0.22% +328 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB - -
@sentry/node - without tracing 74.78 kB +0.46% +340 B 🔺
@sentry/aws-serverless 84.26 kB +0.41% +342 B 🔺
@sentry/cloudflare (withSentry) - minified 196.64 kB - -
@sentry/cloudflare (withSentry) 483.92 kB - -

View base workflow run

@timfish
timfish marked this pull request as ready for review July 22, 2026 17:38
@timfish
timfish requested review from a team as code owners July 22, 2026 17:38
@timfish
timfish requested review from JPeer264, Lms24, isaacs and logaretm and removed request for a team July 22, 2026 17:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 143a4cc. Configure here.

const joinedArgs = execArgv.join(' ');
const importPaths = Array.from(joinedArgs.matchAll(/--import[ =](\S+)/g)).map(e => resolve(cwd, e[1] || ''));
const requirePaths = Array.from(joinedArgs.matchAll(/--require[ =](\S+)/g)).map(e => resolve(cwd, e[1] || ''));
const requirePaths = Array.from(joinedArgs.matchAll(/(?:--require|-r)[ =](\S+)/g)).map(e => resolve(cwd, e[1] || ''));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Require warning misses package preloads

Medium Severity

The new --require migration warning relies on getEntryPointType(), but parseProcessPaths resolves preload targets with path.resolve(cwd, ...). Package specifiers like @sentry/node/init never match real stack filenames under node_modules, so the documented no-code --require entry points silently skip the warning.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 143a4cc. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok

@timfish
timfish merged commit 34eb8bc into develop Jul 23, 2026
416 of 419 checks passed
@timfish
timfish deleted the timfish/feat/no-longer-support---require branch July 23, 2026 10:31
isaacs pushed a commit that referenced this pull request Jul 23, 2026
This PR simplifies the `register.ts` hook registration to remove all the
lazy loading.

Once the lazy loading was removed there were a number of other things
required to get this actually passing all the e2e tests:

- [x] Bundle the whole orchestrion runtime chain (`@apm-js-collab/*`,
meriyah, esquery, …) into `@sentry/server-utils`' build (all now
devDependencies). The dist only has relative requires, which removes two
classes of breakage:
- `require(esm)`: the CJS build is now genuine CJS — fixes AWS Lambda
(`--no-experimental-require-module`) and the `Module.register`
loader-thread crash on Node 22.15–24.12
- Build-time tracer vs runtime exports-map divergence on meriyah's
`module-sync` condition (vercel/nft#603,
nitrojs/nitro#4456) — no runtime package
resolution left to get wrong
- This also reduces the bundler impact of all these dependencies from
+70kB to +20kB
- [x] The `Module.register` async hook is now a self-referenced
entrypoint of our own ESM build
(`@sentry/server-utils/orchestrion/hook`), sharing the vendored chunks
- [x] The webpack/Turbopack loader ships as a bundled entrypoint
(`./orchestrion/webpack-loader`), resolved by self-reference since the
`@apm-js-collab` packages are no longer installed
- [x] Fix build-time Rollup ESM interop issues (Node builtins need
`default` interop; default-only ESM deps need `requireReturnsDefault:
'auto'`)
- [x] NextJS: force `@sentry/server-utils` external via absolute-path
externals so `register.ts` stays in `node_modules` and its
`Module.register` self-reference resolves under pnpm — also removes the
`tracingHooksPath` workaround
- [x] Bumps the `@sentry/node` size limit by ~40kb — the lazy loading
previously hid this code from the size report
- [x] #22513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants