You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bun: Sentry.init() throws when @sentry/bun is loaded with require() #24580
With the CommonJS build of @sentry/bun, Sentry.init() throws in the default bunHttpServerIntegration:
// repro.cjs, run with `bun repro.cjs`constSentry=require('@sentry/bun');Sentry.init({dsn: 'https://public@dsn.ingest.sentry.io/1337'});console.log('init ok');// never printed
TypeError: undefined is not an object (evaluating 'http.default.Server')
at instrumentBunHttpServer (packages/bun/build/cjs/integrations/bunHttpServer.js:42)
at setupOnce (packages/bun/build/cjs/integrations/bunHttpServer.js:15)
Reproduced on Bun 1.3.14 (the CI version) and 1.4.2, on develop (10.67.0). The ESM build (import * as Sentry from '@sentry/bun') is not affected.
Cause.packages/bun/src/integrations/bunHttpServer.ts:2-3 uses default imports (import http from 'node:http', import https from 'node:https'). Rollup emits const http = require('node:http') and then reads http.default.Server (build/cjs/integrations/bunHttpServer.js:42-44). In CommonJS, Bun's node:http has no default property, so init() throws. The integration is in the default set (packages/bun/src/sdk.ts:69), so every require('@sentry/bun') user is affected, not only users of node:http servers.
Work item. Use namespace imports (import * as http from 'node:http'), or fix the CJS interop in the build. Add a regression test that loads @sentry/bun with require() and calls init(), because the existing Bun integration tests use only ESM.
How it was found. The POC that runs the Node integration suites on Bun with @sentry/node mapped to @sentry/bun (#24052) ran public-api/OnUncaughtException/basic.js, a CommonJS scenario. The error event contained this TypeError in place of the expected Error: foo. The bug came in with #22870.
Activity
linear-code commentedon Sep 22, 2026
JS-3746
fix(bun): Use namespace imports for `node:http` in `bunHttpServerInte…
github-actions commentedon Sep 23, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #24584, which was included in the 11.0.0 release.