sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

bun: `Bun.serve` has no `ignoreStatusCodes`

Open isaacs opened this issue 3 months ago • 3 comments

denoServeIntegration exposes ignoreStatusCodes and runs processHttpServerTransactionEvent; httpServerSpansIntegration does the same on Node. bunServerIntegration has no options at all, so 301/302/401/404 transactions are all recorded on Bun.

Work item. Add ignoreStatusCodes to bunServerIntegration, defaulting to DEFAULT_IGNORE_STATUS_CODES, and add the processEvent hook.

**Prior art **(related history only). No issue for Bun. The Deno equivalents shipped as getsentry/sentry-javascript#23313 and getsentry/sentry-javascript#23692 (both merged), which aligned denoHttpIntegration options with httpIntegration. Bun was not part of either.

isaacs avatar Sep 02 '26 04:09 isaacs

JS-3511

linear-code[bot] avatar Sep 02 '26 04:09 linear-code[bot]

This looks superseded by #23973, which was merged the day after this was filed and went out in 11.0.0. It deprecated ignoreStatusCodes on httpIntegration/httpServerSpansIntegration and on denoHttpIntegration/denoServeIntegration, with removal planned for v12 and no direct replacement. The filter runs on transaction events, so it does nothing under the default traceLifecycle: 'stream'. Adding the option to bunServerIntegration now would ship it already deprecated.

I also checked what Bun does today with @sentry/bun 11.8.0 on Bun 1.4.3 (macOS arm64). The test app is a Bun.serve handler that returns 200 for /ok and 404 for /missing, with a custom transport recording the envelopes. Output below is trimmed to the Bun.serve items:

# default (traceLifecycle = stream)
span GET origin auto.http.bun.serve is_segment true status 200
span GET origin auto.http.bun.serve is_segment true status 404

# traceLifecycle: 'static'
transaction GET /ok origin auto.http.bun.serve status 200
client_report: {"reason":"event_processor","category":"transaction","quantity":1}

# traceLifecycle: 'static' + httpIntegration({ ignoreStatusCodes: [] })
transaction GET /ok origin auto.http.bun.serve status 200
transaction GET /missing origin auto.http.bun.serve status 404

So with 'static', the 404 is already dropped on Bun. The Bun SDK includes Node's httpIntegration by default, and its processEvent hands off to httpServerSpansIntegration, which calls processHttpServerTransactionEvent(event, ignoreStatusCodes) without a span origin. The Deno integrations pass one, so this filter also catches auto.http.bun.serve transactions. The description's "all recorded" only holds for the stream lifecycle, and there the option couldn't help anyway.

As long as Node's filter stays unscoped, a Bun-only option scoped to auto.http.bun.serve also couldn't keep anything it drops: in static mode, ignoreStatusCodes: [] on the Bun integration would still lose the 404 unless it's also set on httpIntegration. I tried this with a stand-in processEvent integration scoped to that origin, plus a /boom route that returns 500. Passing everything through still lost the 404, while dropping 500 on top did work.

Closing this in favor of #23956/#23973 seems simplest. A one-line note in the MIGRATION.md deprecation section might still help: on Bun, the httpIntegration option is the one that applies to Bun.serve until v12.

aozmekik avatar Oct 18 '26 05:10 aozmekik

@aozmekik Yes, that is correct. Closing as superseded is the right call. Thanks for the analysis!

isaacs avatar Oct 18 '26 21:10 isaacs