Skip to content

Sentry/bun Errors in the wrong transactions #17490

@brianbegy

Description

@brianbegy

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/bun

SDK Version

10.5.0

Framework Version

No response

Link to Sentry event

https://charlie-labs.sentry.io/issues/trace/cc02b94ca5104225a291675028a33bd0/?fov=1%2C15668.7509765625&groupId=6801482918&node=span-b0eedcf849f592bf&pageEnd=2025-08-30T03%3A57%3A18.676&pageStart=2025-08-29T03%3A57%3A18.676&project=4508798077042688&source=issue_details&timestamp=1756483038.653

Reproduction Example/SDK Setup

We can invite your staff to our repo if needed.

Steps to Reproduce

We are experiencing an issue with errors ending up in the wrong transactions.

We are using @sentry/bun 10.5.0

We have manually instrumented spans with Sentry.withScope and Sentry.createSpan and our global error handler calls captureException. All errors are passed to the next() function from inside the span.

What we find is under load exceptions end up in transactions that are impossible: errors from production appearing on Sentry.io in preview environments, one route handler containing errors from another.

So we are looking for suggestions on how to resolve this.

Expected Result

An error thrown in route1 appears in route1's transaction, not in route2.

Actual Result

Errors appear attached to the wrong transactions.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions