Skip to content

[@sentry/bun] NodeClient always overrides runtime context to 'node', ignoring Bun SDK's runtime option #19269

Description

@BYK

Problem

In @sentry/bun v10, the Bun SDK's init() correctly sets runtime: { name: 'bun', version: Bun.version } on the options object, but then delegates to @sentry/node's init(), which creates a NodeClient. The NodeClient constructor always overrides the runtime:

// @sentry/node-core/build/esm/sdk/client.js, NodeClient constructor
const clientOptions = {
    ...options,           // ← spreads bun's runtime: { name: 'bun', version: '1.x.x' }
    platform: 'node',
    runtime: { name: 'node', version: global.process.version },  // ← OVERRIDES it
    serverName,
};

Because runtime comes after ...options in the object literal, the Bun SDK's runtime is always overridden with { name: 'node' }.

Under Bun, global.process.version returns the Node.js compatibility version (e.g., v24.3.0), not the actual Bun version. This means:

  • event.contexts.runtime incorrectly shows { name: 'node', version: 'v24.3.0' } for events sent from Bun
  • Sentry's server-side tag promotion creates a runtime tag with value node instead of bun

Expected Behavior

When using @sentry/bun, event.contexts.runtime should be { name: 'bun', version: '<actual bun version>' }, and the server-side promoted runtime tag should show bun.

Reproduction

import * as Sentry from "@sentry/bun";

const client = Sentry.init({ dsn: "..." });
console.log(client?.getOptions().runtime);
// Actual:   { name: 'node', version: 'v24.3.0' }
// Expected: { name: 'bun', version: '1.3.8' }

Context

This was BunClient's job (it correctly set runtime: { name: 'bun' }), but BunClient was deprecated in v9/v10 and the Bun SDK now delegates entirely to @sentry/node's init()NodeClient.

Suggested Fix

In NodeClient's constructor, respect the runtime option if it was already set by a wrapping SDK:

const clientOptions = {
    ...options,
    platform: 'node',
    runtime: options.runtime || { name: 'node', version: global.process.version },
    serverName,
};

Or alternatively, in @sentry/bun's init(), override the runtime after NodeClient is created:

const client = init$1(options);
if (client) {
    client.getOptions().runtime = { name: 'bun', version: Bun.version };
}
return client;

Workaround

We're currently working around this by mutating client.getOptions().runtime after Sentry.init():

const client = Sentry.init({ ... });
if (client && typeof process.versions.bun !== "undefined") {
    (client.getOptions() as any).runtime = {
        name: "bun",
        version: process.versions.bun,
    };
}

Versions

  • @sentry/bun: 10.38.0
  • @sentry/node: 10.38.0
  • @sentry/core: 10.38.0
  • Bun: 1.3.8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions