Title: bun: `Sentry.init()` throws when `@sentry/bun` is loaded with `require()` · Issue #24580 · getsentry/sentry-javascript · GitHub
Open Graph Title: bun: `Sentry.init()` throws when `@sentry/bun` is loaded with `require()` · Issue #24580 · getsentry/sentry-javascript
X Title: bun: `Sentry.init()` throws when `@sentry/bun` is loaded with `require()` · Issue #24580 · getsentry/sentry-javascript
Description: With the CommonJS build of @sentry/bun, Sentry.init() throws in the default bunHttpServerIntegration: // repro.cjs, run with `bun repro.cjs` const Sentry = require('@sentry/bun'); Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1...
Open Graph Description: With the CommonJS build of @sentry/bun, Sentry.init() throws in the default bunHttpServerIntegration: // repro.cjs, run with `bun repro.cjs` const Sentry = require('@sentry/bun'); Sentry.init({ dsn...
X Description: With the CommonJS build of @sentry/bun, Sentry.init() throws in the default bunHttpServerIntegration: // repro.cjs, run with `bun repro.cjs` const Sentry = require('@sentry/bun'); Sentry.in...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/24580
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bun: `Sentry.init()` throws when `@sentry/bun` is loaded with `require()`","articleBody":"With the CommonJS build of `@sentry/bun`, `Sentry.init()` throws in the default `bunHttpServerIntegration`:\n\n```js\n// repro.cjs, run with `bun repro.cjs`\nconst Sentry = require('@sentry/bun');\n\nSentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337' });\nconsole.log('init ok'); // never printed\n```\n\n```\nTypeError: undefined is not an object (evaluating 'http.default.Server')\n at instrumentBunHttpServer (packages/bun/build/cjs/integrations/bunHttpServer.js:42)\n at setupOnce (packages/bun/build/cjs/integrations/bunHttpServer.js:15)\n```\n\nReproduced 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.\n\n**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.\n\n**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.\n\n**How it was found.** The POC that runs the Node integration suites on Bun with `@sentry/node` mapped to `@sentry/bun` (getsentry/sentry-javascript#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 getsentry/sentry-javascript#22870.","author":{"url":"https://github.com/JPeer264","@type":"Person","name":"JPeer264"},"datePublished":"2026-09-22T08:52:31Z","url":"https://github.com/getsentry/sentry-javascript/issues/24580"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b59fb907-3f3e-f3d3-d92e-964942ca9f22 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D892:F4D72:77407C:A32937:6B044841 |
| html-safe-nonce | 475e73a3ea826593802e8aa0a38a1faf085a4fe6eda46f539d4e55162113fe56 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODkyOkY0RDcyOjc3NDA3QzpBMzI5Mzc6NkIwNDQ4NDEiLCJ2aXNpdG9yX2lkIjoiNjk0NzczMjE4MDA1OTgzNDQzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | df13957a07f471eaf8ffd39474f34a6947be12d73b7b45a2f8cbeca3b2591135 |
| hovercard-subject-tag | issue:5537350591 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/24580/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b7f26c056ce7ff0cd9f106d6fb35cd4d0496cba05ea904c28afa6e9018647cd/getsentry/sentry-javascript/issues/24580 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b7f26c056ce7ff0cd9f106d6fb35cd4d0496cba05ea904c28afa6e9018647cd/getsentry/sentry-javascript/issues/24580 |
| og:image:alt | With the CommonJS build of @sentry/bun, Sentry.init() throws in the default bunHttpServerIntegration: // repro.cjs, run with `bun repro.cjs` const Sentry = require('@sentry/bun'); Sentry.init({ dsn... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JPeer264 |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width