fix(telemetry): correct runtime context for Bun binary#231
Merged
Conversation
`@sentry/bun` v10 delegates to `@sentry/node`'s `NodeClient`, which
always overrides the runtime option to `{ name: 'node' }` regardless of
what the Bun SDK set. Under Bun, `process.version` returns the Node.js
compat version (e.g. v24.3.0), causing event.contexts.runtime and the
server-promoted `runtime` tag to incorrectly show `node`.
Fix by overriding `client.getOptions().runtime` after `Sentry.init()`
with the correct Bun runtime info. The `cli.runtime` tag is kept for
backward compatibility with existing dashboards.
Upstream: getsentry/sentry-javascript#19269
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 3871 uncovered lines. Files with missing lines (67)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 69.85% 69.87% +0.02%
==========================================
Files 105 105 —
Lines 12841 12848 +7
Branches 0 0 —
==========================================
+ Hits 8970 8977 +7
- Misses 3871 3871 —
- Partials 0 0 —Generated by Codecov Action |
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.
Summary
runtimetag/context showingnodeinstead ofbunfor native Bun binaryclient.getOptions().runtimeafterSentry.init()to work around@sentry/bunv10 bug whereNodeClientalways overrides the runtime optioncli.runtimetag for backward compatibility with existing dashboardsProblem
@sentry/bunv10 delegates to@sentry/node'sNodeClient, which always overridesruntimeto{ name: 'node', version: process.version }. Under Bun,process.versionreturns the Node.js compat version (e.g.v24.3.0), causingevent.contexts.runtimeand the server-promotedruntimetag to incorrectly shownode.Fix
Override
client.getOptions().runtimeafterSentry.init()with the correct Bun runtime info.Sentry.setContext()doesn't work here becauseServerRuntimeClient._prepareEvent()runs before scope context merging and its result takes precedence.Upstream issue: getsentry/sentry-javascript#19269