Skip to content

fix(telemetry): correct runtime context for Bun binary#231

Merged
BYK merged 1 commit intomainfrom
fix/bun-runtime-context
Feb 11, 2026
Merged

fix(telemetry): correct runtime context for Bun binary#231
BYK merged 1 commit intomainfrom
fix/bun-runtime-context

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 11, 2026

Summary

  • Fix incorrect runtime tag/context showing node instead of bun for native Bun binary
  • Override client.getOptions().runtime after Sentry.init() to work around @sentry/bun v10 bug where NodeClient always overrides the runtime option
  • Keep cli.runtime tag for backward compatibility with existing dashboards

Problem

@sentry/bun v10 delegates to @sentry/node's NodeClient, which always overrides runtime to { name: 'node', version: process.version }. 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

Override client.getOptions().runtime after Sentry.init() with the correct Bun runtime info. Sentry.setContext() doesn't work here because ServerRuntimeClient._prepareEvent() runs before scope context merging and its result takes precedence.

Upstream issue: getsentry/sentry-javascript#19269

`@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
@github-actions
Copy link
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (telemetry) Correct runtime context for Bun binary by BYK in #231

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 3871 uncovered lines.
✅ Project coverage is 69.87%. Comparing base (base) to head (head).

Files with missing lines (67)
File Patch % Lines
human.ts 56.16% ⚠️ 395 Missing
resolve-target.ts 20.26% ⚠️ 366 Missing
list.ts 14.39% ⚠️ 345 Missing
api-client.ts 66.37% ⚠️ 230 Missing
list.ts 23.47% ⚠️ 212 Missing
oauth.ts 25.10% ⚠️ 194 Missing
list.ts 21.96% ⚠️ 167 Missing
plan.ts 19.37% ⚠️ 154 Missing
help.ts 19.85% ⚠️ 109 Missing
upgrade.ts 57.71% ⚠️ 107 Missing
view.ts 36.48% ⚠️ 101 Missing
interactive-login.ts 9.17% ⚠️ 99 Missing
view.ts 25.81% ⚠️ 92 Missing
view.ts 39.44% ⚠️ 86 Missing
clipboard.ts 4.49% ⚠️ 85 Missing
status.ts 24.07% ⚠️ 82 Missing
migration.ts 47.44% ⚠️ 82 Missing
list.ts 27.18% ⚠️ 75 Missing
browser.ts 4.11% ⚠️ 70 Missing
login.ts 33.33% ⚠️ 64 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
explain.ts 33.33% ⚠️ 56 Missing
telemetry.ts 80.35% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
upgrade.ts 66.91% ⚠️ 46 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
refresh.ts 40.63% ⚠️ 38 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
view.ts 87.27% ⚠️ 28 Missing
utils.ts 88.94% ⚠️ 25 Missing
view.ts 61.54% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
binary.ts 88.67% ⚠️ 17 Missing
list.ts 91.16% ⚠️ 16 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
help.ts 57.14% ⚠️ 15 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
logout.ts 56.00% ⚠️ 11 Missing
token.ts 52.17% ⚠️ 11 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
view.ts 94.70% ⚠️ 7 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.76% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
shell.ts 96.23% ⚠️ 6 Missing
app.ts 93.59% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
setup.ts 97.84% ⚠️ 4 Missing
list.ts 97.33% ⚠️ 4 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
output.ts 89.47% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
completions.ts 99.37% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 97.96% ⚠️ 1 Missing
trace.ts 99.16% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
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

@BYK BYK marked this pull request as ready for review February 11, 2026 01:06
@BYK BYK enabled auto-merge (squash) February 11, 2026 01:06
@BYK BYK merged commit 660a04b into main Feb 11, 2026
23 checks passed
@BYK BYK deleted the fix/bun-runtime-context branch February 11, 2026 01:07
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