Skip to content

fix(node): Vendor InstrumentationNodeModuleFile to fix Bun --bytecode crash - #21262

Merged
s1gr1d merged 6 commits into
developfrom
fix/bun-bytecode-graphql-normalize
Jun 1, 2026
Merged

fix(node): Vendor InstrumentationNodeModuleFile to fix Bun --bytecode crash#21262
s1gr1d merged 6 commits into
developfrom
fix/bun-bytecode-graphql-normalize

Conversation

@s1gr1d

Copy link
Copy Markdown
Member

InstrumentationNodeModuleFile from @opentelemetry/instrumentation resolves path.normalize. When Bun's --bytecode compiler inlines the module tree into a single flat bundle, it renames normalize to normalize4 and then loses the scope binding in bytecode compilation, producing a ReferenceError at runtime.

Vendor a local InstrumentationNodeModuleFile class that calls path.normalize() directly, replacing the import from @opentelemetry/instrumentation in all vendored instrumentations within @sentry/node.

Closes#21256

@s1gr1d
s1gr1d requested a review from a team as a code ownerJune 1, 2026 09:45
@s1gr1d
s1gr1d requested review from JPeer264, andreiborza and nicohrubec and removed request for a teamJune 1, 2026 09:45

@JPeer264JPeer264 left a comment

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.

LGTM. Is it worth to add a test case for this?

FYI the build is failing for node

@github-actions

github-actionsBot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.17 kB--
@sentry/browser - with treeshaking flags25.62 kB--
@sentry/browser (incl. Tracing)45.25 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.47 kB--
@sentry/browser (incl. Tracing, Profiling)50.22 kB--
@sentry/browser (incl. Tracing, Replay)84.83 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.39 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.53 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.15 kB--
@sentry/browser (incl. Feedback)44.34 kB--
@sentry/browser (incl. sendFeedback)31.98 kB--
@sentry/browser (incl. FeedbackAsync)37.08 kB--
@sentry/browser (incl. Metrics)28.25 kB--
@sentry/browser (incl. Logs)28.48 kB--
@sentry/browser (incl. Metrics & Logs)29.19 kB--
@sentry/react28.99 kB--
@sentry/react (incl. Tracing)47.51 kB--
@sentry/vue32.2 kB--
@sentry/vue (incl. Tracing)47.16 kB--
@sentry/svelte27.19 kB--
CDN Bundle29.55 kB--
CDN Bundle (incl. Tracing)47.81 kB--
CDN Bundle (incl. Logs, Metrics)31.05 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.04 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.31 kB--
CDN Bundle (incl. Tracing, Replay)85.18 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.35 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.05 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.21 kB--
CDN Bundle - uncompressed87.59 kB--
CDN Bundle (incl. Tracing) - uncompressed144.09 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed92.08 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed147.85 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed216.81 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed262.87 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed266.61 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed276.57 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed280.3 kB--
@sentry/nextjs (client)50.02 kB--
@sentry/sveltekit (client)45.68 kB--
@sentry/core/server76.56 kB--
@sentry/core/browser63.09 kB--
@sentry/node-core61.69 kB+0.01%+1 B 🔺
@sentry/node130.42 kB-0.12%-147 B 🔽
@sentry/node - without tracing74.1 kB+0.01%+1 B 🔺
@sentry/aws-serverless86.29 kB+0.01%+1 B 🔺
@sentry/cloudflare (withSentry) - minified171.64 kB--
@sentry/cloudflare (withSentry)429.7 kB--

View base workflow run

@s1gr1d
s1gr1d enabled auto-merge (squash) June 1, 2026 13:07
@s1gr1d
s1gr1d merged commit 4940dd8 into developJun 1, 2026
267 of 268 checks passed
@s1gr1d
s1gr1d deleted the fix/bun-bytecode-graphql-normalize branch June 1, 2026 13:23
Sign up for freeto 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.

@sentry/bun - Bun compile fails with --bytecode build flag

2 participants

@s1gr1d@JPeer264