Skip to content

fix(server-runtime-injection): Keep ES modules working on Deno - #24669

Open
JPeer264 wants to merge 1 commit into
jp/node-suites-bunfrom
jp/node-suites-deno-esm-fix
Open

JPeer264 wants to merge 1 commit into
jp/node-suites-bunfrom
jp/node-suites-deno-esm-fix

Conversation

@JPeer264

@JPeer264 JPeer264 commented Sep 23, 2026

Copy link
Copy Markdown
Member

With deno run --preload=npm:@sentry/deno/import, an instrumented library that ships an ES module build crashed on import with ReferenceError: require is not defined. Deno's module hooks report no format for an ES module, so the orchestrion transform treated it as CommonJS and injected a require() into it. This hit the ESM builds of the AI SDKs and postgres, among others.

The Deno load hook now restores the format of .mjs files and of .js files in a "type": "module" package, the same way it already did for JSON (#24412). It restores it on the nextLoad result, because the transform reads the format there.

Running the shared Node integration suites on Deno found this. The next PR in the stack runs them in CI; the Deno-only orchestrion suites did not catch it because they publish fake channel messages instead of loading the real libraries.

Part of #24052 and #23897.

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

JS-3587

JS-3523

@JPeer264
JPeer264 added this pull request to stack #24670 September 23, 2026 16:19
@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.23 kB -0.03% -6 B 🔽
@sentry/browser - with treeshaking flags 27.49 kB -0.04% -10 B 🔽
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB -0.01% -1 B 🔽
@sentry/browser (incl. Tracing) 51.16 kB +0.01% +3 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB -0.02% -8 B 🔽
@sentry/browser (incl. Tracing, Profiling) 54.16 kB -0.03% -12 B 🔽
@sentry/browser (incl. Tracing, Replay) 90.75 kB -0.02% -15 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.85 kB -0.02% -11 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 95.45 kB -0.02% -18 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 108.42 kB +0.01% +9 B 🔺
@sentry/browser (incl. Feedback) 46.76 kB -0.02% -8 B 🔽
@sentry/browser (incl. sendFeedback) 34.29 kB -0.03% -10 B 🔽
@sentry/browser (incl. FeedbackAsync) 39.39 kB -0.06% -22 B 🔽
@sentry/browser (incl. Metrics) 30.25 kB -0.01% -2 B 🔽
@sentry/browser (incl. Logs) 30.5 kB -0.05% -14 B 🔽
@sentry/browser (incl. Metrics & Logs) 31.16 kB -0.05% -14 B 🔽
@sentry/react 30.98 kB -0.05% -14 B 🔽
@sentry/react (incl. Tracing) 53.44 kB -0.02% -6 B 🔽
@sentry/vue 36.72 kB -0.05% -15 B 🔽
@sentry/vue (incl. Tracing) 53.69 kB -0.03% -12 B 🔽
@sentry/svelte 29.25 kB -0.03% -8 B 🔽
CDN Bundle 30.93 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing) 51.69 kB +0.01% +5 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.19 kB -0.03% -9 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 53.66 kB -0.02% -7 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 73.91 kB -0.01% -3 B 🔽
CDN Bundle (incl. Tracing, Replay) 89.27 kB -0.02% -9 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.23 kB -0.02% -11 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 95.43 kB -0.02% -19 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.41 kB -0.02% -11 B 🔽
CDN Bundle - uncompressed 91.4 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 153.76 kB -0.01% -8 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.72 kB -0.01% -8 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.49 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.43 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.2 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.13 kB -0.01% -8 B 🔽
@sentry/nextjs (client) 55.78 kB +0.02% +6 B 🔺
@sentry/sveltekit (client) 51.58 kB -0.03% -11 B 🔽
@sentry/core/server 39.92 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 133.96 kB +0.08% +106 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.57 kB +0.21% +172 B 🔺
@sentry/node - without tracing 90.48 kB +0.1% +90 B 🔺
@sentry/node - without channel injection 112.4 kB +0.02% +17 B 🔺
@sentry/aws-serverless 98.78 kB +0.12% +113 B 🔺
@sentry/cloudflare (withSentry) - minified 206.38 kB -0.01% -12 B 🔽
@sentry/cloudflare (withSentry) 513.49 kB -0.01% -26 B 🔽

View base workflow run

Deno's module hooks report no `format` for an ES module, so the
orchestrion transform treated it as CommonJS and injected a `require()`
that throws when the module loads. This broke `@sentry/node` on Deno for
the ESM builds of libraries it instruments, such as the AI SDKs and
`postgres`. The Deno load hook now restores the format of `.mjs` files
and of `.js` files in a `"type": "module"` package, the same way it
already did for JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/node-suites-deno-esm-fix branch from 055e26b to 540f4fe Compare September 23, 2026 16:40
@JPeer264 JPeer264 self-assigned this Sep 23, 2026
@JPeer264
JPeer264 removed this pull request from stack #24670 September 23, 2026 17:26
@JPeer264
JPeer264 added this pull request to stack #24671 September 23, 2026 17:31
@JPeer264
JPeer264 marked this pull request as ready for review September 23, 2026 17:35
@JPeer264
JPeer264 requested a review from a team as a code owner September 23, 2026 17:35
@JPeer264
JPeer264 requested review from andreiborza, isaacs, logaretm and stephanie-anderson and removed request for a team, logaretm and stephanie-anderson September 23, 2026 17:35

This branch has not been deployed

No deployments
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.

1 participant