feat(node)!: Remove import-in-the-middle ESM loader and deprecated instrumentation base - #22755
Merged
Conversation
…strumentation base With all vendored OpenTelemetry instrumentations removed, `@sentry/node` no longer has any import-in-the-middle module patchers. This removes the remaining iitm plumbing: - Remove the `registerEsmLoaderHooks` option and drop the `import-in-the-middle` dependency; the SDK no longer registers ESM loader hooks. - Delete the shared `InstrumentationNodeModuleFile` helper and the ESM loader. - Remove the deprecated `SentryHttpInstrumentation` and `SentryNodeFetchInstrumentation` classes (the diagnostics-channel-based `instrumentHttpOutgoingRequests` / `instrumentUndici` functions are kept). Closes: #22346 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add the `registerEsmLoaderHooks` option removal to the v11 migration guide, and fold `SentryNodeFetchInstrumentation` into the existing `SentryHttpInstrumentation` removal entry.
andreiborza
commented
Jul 28, 2026
| "@sentry/opentelemetry": "10.67.0", | ||
| "@sentry/server-utils": "10.67.0", | ||
| "@sentry/bundler-plugins": "10.67.0", | ||
| "import-in-the-middle": "^3.0.0" |
Member
Author
|
Removing |
Contributor
size-limit report 📦
|
Both packages inject `import 'import-in-the-middle/hook.mjs'` into their built server output and previously relied on the package being present transitively through `@sentry/node`. Now that `@sentry/node` no longer depends on it, they must declare it directly, otherwise the built server fails to start with `ERR_MODULE_NOT_FOUND` for `import-in-the-middle/hook.mjs`.
This reverts commit a844096.
Both packages injected `import 'import-in-the-middle/hook.mjs'` into their built server entry so bundlers would include the file for `@sentry/node`'s esmLoader to `module.register()` at runtime. With the esmLoader removed, nothing registers the hook anymore (the file is inert on import), so the injection only forced a now-dead dependency into the output and broke server startup with `ERR_MODULE_NOT_FOUND`. Drops the injection (and the solidstart `additionalImports` plumbing that existed solely for it).
andreiborza
marked this pull request as ready for review
July 28, 2026 14:13
andreiborza
requested review from
a team,
JPeer264,
chargome,
isaacs,
mydea,
nicohrubec and
s1gr1d
and removed request for
a team
July 28, 2026 14:13
chargome
reviewed
Jul 28, 2026
Comment on lines
+16
to
+19
| - feat(node)!: Remove `import-in-the-middle`-based instrumentations from `@sentry/node`. All performance integrations are now channel-based via `@sentry/server-utils`. As part of this: | ||
| - The `registerEsmLoaderHooks` option was removed from `NodeOptions`. The SDK no longer registers `import-in-the-middle` ESM loader hooks, and `import-in-the-middle` is no longer a dependency. | ||
| - `knexIntegration` and `dataloaderIntegration` are now channel-only and no longer fall back to OpenTelemetry instrumentation on runtimes without diagnostics-channel injection. | ||
| - Support for Fastify `<3.21.0` was dropped. |
Member
Author
There was a problem hiding this comment.
What is this? The entire changelog entry you mean or dropping fastify?
Member
Author
There was a problem hiding this comment.
Tbh I think the changelog entry is useless anyway, I'll remove
chargome
approved these changes
Jul 28, 2026
…mbing # Conflicts: # packages/node/src/utils/detection.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4ed3550. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Final cleanup PR. Once the vendored OpenTelemetry instrumentations are gone,
@sentry/nodehas no import-in-the-middle module patchers left, so this removes the remaining iitm plumbing:registerEsmLoaderHooksoption fromNodeOptionsand drop theimport-in-the-middledependency.InstrumentationNodeModuleFilehelper,esmLoader.ts, and the ESM-loader detection util.SentryHttpInstrumentationandSentryNodeFetchInstrumentationclasses. The live diagnostics-channel-basedinstrumentHttpOutgoingRequests/instrumentUndicifunctions are kept.esm/import-in-the-middleintegration-test suite and add the changelog entry.Why
These were the last pieces tying
@sentry/nodeto import-in-the-middle. All performance integrations are channel-based via@sentry/server-utils(default since #22501), so the ESM loader hook served nothing.Closes: #22346