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

@s1gr1d s1gr1d commented Jun 1, 2026

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 owner June 1, 2026 09:45
@s1gr1d s1gr1d requested review from JPeer264, andreiborza and nicohrubec and removed request for a team June 1, 2026 09:45
Copy link
Copy Markdown
Member

@JPeer264 JPeer264 left a comment

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.17 kB - -
@sentry/browser - with treeshaking flags 25.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 flags 74.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/react 28.99 kB - -
@sentry/react (incl. Tracing) 47.51 kB - -
@sentry/vue 32.2 kB - -
@sentry/vue (incl. Tracing) 47.16 kB - -
@sentry/svelte 27.19 kB - -
CDN Bundle 29.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 - uncompressed 87.59 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.09 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 92.08 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.85 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 216.81 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.87 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.57 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.3 kB - -
@sentry/nextjs (client) 50.02 kB - -
@sentry/sveltekit (client) 45.68 kB - -
@sentry/core/server 76.56 kB - -
@sentry/core/browser 63.09 kB - -
@sentry/node-core 61.69 kB +0.01% +1 B 🔺
@sentry/node 130.42 kB -0.12% -147 B 🔽
@sentry/node - without tracing 74.1 kB +0.01% +1 B 🔺
@sentry/aws-serverless 86.29 kB +0.01% +1 B 🔺
@sentry/cloudflare (withSentry) - minified 171.64 kB - -
@sentry/cloudflare (withSentry) 429.7 kB - -

View base workflow run

Comment thread packages/node/test/integrations/tracing/instrumentationNodeModuleFile.test.ts Outdated
@s1gr1d s1gr1d enabled auto-merge (squash) June 1, 2026 13:07
@s1gr1d s1gr1d merged commit 4940dd8 into develop Jun 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 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.

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

2 participants