Skip to content

Bun instrumentation stops working if reload is called on the server #15144

Closed
@nathankleyn

Description

@nathankleyn

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

8.51.0

Framework Version

Bun 1.1.45

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
  tracesSampleRate: 1.0,
  environment: "some_env",
});

// server before reloading is instrumented
const server = Bun.serve({
  async fetch(_req) {
    throw new Error("I should have instrumentation, and I do");
  },
  port: 3000,
});

// server after reloading is not instrumented
server.reload({
  async fetch(_req) {
    throw new Error("I should have instrumentation, but I don't");
  },
})

await fetch('http://localhost:3000/');

Steps to Reproduce

  1. Create a Bun server
  2. Reload the server
  3. Throw an error in the handler and look at the Sentry error

Reloading is done out of the box by some frameworks built on top of Bun Serve, like ElysiaJS (which does it after AOT / precompilation is completed).

Expected Result

The error should have instrumentation, such as request URL, request headers, browser information and trace information:

Image

Actual Result

The error has no instrumentation at all:

Image

Metadata

Metadata

Assignees

Labels

Package: bunIssues related to the Sentry Bun SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions