chore: Remove lazy loading for hook registration#22443
Conversation
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2705b96. Configure here.
isaacs
left a comment
There was a problem hiding this comment.
The only thing I'd gate on is the license banner preservation, to stay on the right side of the MIT/ISC/Apache/BSD code this bundles.
But, I think it's absolutely the right way to go, and overall works as expected.
| (denoVersion[0] ?? 0) > 2 || | ||
| (denoVersion[0] === 2 && (denoVersion[1] ?? 0) >= 8) | ||
| ); | ||
| if (denoVersionString) { |
There was a problem hiding this comment.
I wonder if the deno test is still necessary, since our minimum Deno version is going to be 2.8.2 in v11?
| // `strictRequires: false`: the default `'auto'` wraps conditionally-required modules (e.g. | ||
| // `debug`'s browser/node split) in lazy initializers exported as `__require` — an export name that | ||
| // downstream re-bundlers mishandle (Turbopack renames it, producing `.require is not a function` | ||
| // crashes in Next.js on Cloudflare). Hoisting is safe here: the vendored graph is closed (nothing | ||
| // optional/missing) and has no require cycles that depend on lazy evaluation. | ||
| const commonJSOptions = { transformMixedEsModules: true, requireReturnsDefault: 'auto', strictRequires: false }; |
There was a problem hiding this comment.
(low/safety) It'd be good to have a smoke test that verifies this, if only to prevent us from upgrading and breaking something down the road, if meriyah or apm-js-collab stuff ever violates that assumption.
There was a problem hiding this comment.
LGTM! Checking with our oss legal brain trust now about the third-party-licenses.txt thing, but we can always patch it (or back this out) before cutting a v11 release, if they find any problems with the approach.
Update: Sentry counsel says this is the way, so we're good. Third-party bundle is obvious in the build artifact, and the single collected license declaration is standard practice. 👍
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.
develop's hook-registration rework (#22443) resolves the bundled-pnpm specifier via absolute-path webpack externals and dropped the tracingHooksDir option from registerDiagnosticsChannelInjection and the _sentryOrchestrionTracingHooksDir build var. Remove the now-broken nextjs workaround that relied on them; node's init registers the hooks and the externals keep them resolvable.

This PR simplifies the
register.tshook registration to remove all the lazy loading. The clankers seem to always resort to lazy loading but pushed hard enough they will find better alternatives 🤣Once the lazy loading was removed there were a number of other things required to get this actually passing all the e2e tests:
@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 theModule.registerloader-thread crash on Node 22.15–24.12module-synccondition (Traced file set depends on the Node version running the trace (module-syncgated on build-time Node >= 22) vercel/nft#603, Nested dependency silently missing when its exports map has noimportcondition nitrojs/nitro#4456) — no runtime package resolution left to get wrongModule.registerasync hook is now a self-referenced entrypoint of our own ESM build (@sentry/server-utils/orchestrion/hook), sharing the vendored chunks./orchestrion/webpack-loader), resolved by self-reference since the@apm-js-collabpackages are no longer installeddefaultinterop; default-only ESM deps needrequireReturnsDefault: 'auto')@sentry/server-utilsexternal via absolute-path externals soregister.tsstays innode_modulesand itsModule.registerself-reference resolves under pnpm — also removes thetracingHooksPathworkaround@sentry/nodesize limit by ~40kb — the lazy loading previously hid this code from the size report--require#22513