Skip to content

feat(node)!: Remove import-in-the-middle ESM loader and deprecated instrumentation base - #22755

Merged
andreiborza merged 9 commits into
developfrom
ab/remove-iitm-plumbing
Jul 28, 2026
Merged

feat(node)!: Remove import-in-the-middle ESM loader and deprecated instrumentation base#22755
andreiborza merged 9 commits into
developfrom
ab/remove-iitm-plumbing

Conversation

@andreiborza

@andreiborza andreiborza commented Jul 28, 2026

Copy link
Copy Markdown
Member

What

Final cleanup PR. Once the vendored OpenTelemetry instrumentations are gone, @sentry/node has no import-in-the-middle module patchers left, so this removes the remaining iitm plumbing:

  • Remove the registerEsmLoaderHooks option from NodeOptions and drop the import-in-the-middle dependency.
  • Delete the shared InstrumentationNodeModuleFile helper, esmLoader.ts, and the ESM-loader detection util.
  • Remove the deprecated SentryHttpInstrumentation and SentryNodeFetchInstrumentation classes. The live diagnostics-channel-based instrumentHttpOutgoingRequests / instrumentUndici functions are kept.
  • Delete the now-obsolete esm/import-in-the-middle integration-test suite and add the changelog entry.

Why

These were the last pieces tying @sentry/node to import-in-the-middle. All performance integrations are channel-based via @sentry/server-utils (default since #22501), so the ESM loader hook served nothing.

Depends on the per-integration removal PRs. This branch deletes InstrumentationNodeModuleFile, which the vendored instrumentations still import on develop, so CI here stays red until those PRs merge. It should be merged last.

Closes: #22346

…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>
Comment thread packages/node/src/types.ts
andreiborza and others added 2 commits July 28, 2026 13:23
Add the `registerEsmLoaderHooks` option removal to the v11 migration guide, and
fold `SentryNodeFetchInstrumentation` into the existing `SentryHttpInstrumentation`
removal entry.
"@sentry/opentelemetry": "10.67.0",
"@sentry/server-utils": "10.67.0",
"@sentry/bundler-plugins": "10.67.0",
"import-in-the-middle": "^3.0.0"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Image

@andreiborza

Copy link
Copy Markdown
Member Author

Removing @opentelemetry/instrumentation is a bigger task, split into: #22759

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.84 kB - -
@sentry/browser - with treeshaking flags 28.05 kB - -
@sentry/browser (incl. Tracing) 47.41 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.42 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.15 kB - -
@sentry/browser (incl. Tracing, Replay) 86.74 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.15 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 104.11 kB - -
@sentry/browser (incl. Feedback) 47.15 kB - -
@sentry/browser (incl. sendFeedback) 34.68 kB - -
@sentry/browser (incl. FeedbackAsync) 39.77 kB - -
@sentry/browser (incl. Metrics) 30.91 kB - -
@sentry/browser (incl. Logs) 31.14 kB - -
@sentry/browser (incl. Metrics & Logs) 31.82 kB - -
@sentry/react 31.63 kB - -
@sentry/react (incl. Tracing) 49.63 kB - -
@sentry/vue 34.76 kB - -
@sentry/vue (incl. Tracing) 49.36 kB - -
@sentry/svelte 29.87 kB - -
CDN Bundle 31.89 kB - -
CDN Bundle (incl. Tracing) 47.76 kB - -
CDN Bundle (incl. Logs, Metrics) 33.43 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.14 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.79 kB - -
CDN Bundle (incl. Tracing, Replay) 85.39 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.67 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.46 kB - -
CDN Bundle - uncompressed 95.09 kB - -
CDN Bundle (incl. Tracing) - uncompressed 143.22 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.2 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.56 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.45 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.14 kB - -
@sentry/nextjs (client) 52.23 kB - -
@sentry/sveltekit (client) 47.83 kB - -
@sentry/core/server 79.77 kB - -
@sentry/core/browser 51.6 kB - -
@sentry/node 121.06 kB -1.08% -1.31 kB 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 84.48 kB -1.49% -1.27 kB 🔽
@sentry/aws-serverless 92.7 kB -1.15% -1.07 kB 🔽
@sentry/cloudflare (withSentry) - minified 197.51 kB - -
@sentry/cloudflare (withSentry) 485.76 kB - -

View base workflow run

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`.
Comment thread packages/nuxt/package.json Outdated
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
andreiborza marked this pull request as ready for review July 28, 2026 14:13
@andreiborza
andreiborza requested review from a team as code owners July 28, 2026 14:13
@andreiborza
andreiborza requested review from a team, JPeer264, chargome, isaacs, mydea, nicohrubec and s1gr1d and removed request for a team July 28, 2026 14:13
Comment thread CHANGELOG.md Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was this intentional?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What is this? The entire changelog entry you mean or dropping fastify?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Tbh I think the changelog entry is useless anyway, I'll remove

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Gone in c030493

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

steve-carrell-magic

…mbing

# Conflicts:
#	packages/node/src/utils/detection.ts

@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 4ed3550. Configure here.

Comment thread packages/node/src/sdk/index.ts
@andreiborza
andreiborza merged commit e26cf53 into develop Jul 28, 2026
185 checks passed
@andreiborza
andreiborza deleted the ab/remove-iitm-plumbing branch July 28, 2026 15:18
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.

Remove iitm-based instrumentations from @sentry/node

2 participants