Repository navigation
@sentry/bun throws "TypeError: Cannot replace module namespace object's binding with configurable attribute" #12891
Copy link
Copy link
Closed
Labels
BugBunExternal DependencyTo close this issue, an external dependency needs to be adjusted/fixedTo close this issue, an external dependency needs to be adjusted/fixedState: Blocked
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/bun
SDK Version
8.17.0
Framework Version
Bun 1.1.18
Link to Sentry event
https://reserve-sense.sentry.io/issues/5597727361/?project=4506890995499008
SDK Setup/Reproduction Example
import { init } from '@sentry/bun';
init({
dsn: '__MY_DSN__',
tracesSampleRate: 0.5,
});
Steps to Reproduce
I'm adding Sentry to my Bun API and I simply added a basic init() call at the start of my server and it immediately crashes with the error below.
I'm using node-file-router and looks like combining it with the init() call causes issues. My code for that is:
import { initFileRouter } from 'node-file-router';
const runFileRouter = await initFileRouter({
ignoreFilesRegex: [/.\.test/],
});
Expected Result
No failure
Actual Result
App crashes with:
9 |
10 | // Sets a property on an object, preserving its enumerability.
11 | // This function assumes that the property is already writable.
12 | function defineProperty (obj, name, value) {
13 | var enumerable = !!obj[name] && obj.propertyIsEnumerable(name)
14 | Object.defineProperty(obj, name, {
^
TypeError: Cannot replace module namespace object's binding with configurable attribute
at defineProperty (native:1:1)
at defineProperty (/myproject/node_modules/.pnpm/shimmer@1.2.1/node_modules/shimmer/index.js:14:10)
at wrap (/myproject/node_modules/.pnpm/shimmer@1.2.1/node_modules/shimmer/index.js:74:3)
at /myproject/node_modules/.pnpm/@opentelemetry+instrumentation-http@0.52.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation-http/build/src/http.js:78:13
at /myproject/node_modules/.pnpm/@opentelemetry+instrumentation@0.52.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/instrumentation/build/src/platform/node/RequireInTheMiddleSingleton.js:67:27
at /myproject/node_modules/.pnpm/require-in-the-middle@7.3.0/node_modules/require-in-the-middle/index.js:281:28
at /myproject/node_modules/.pnpm/@smithy+node-http-handler@3.1.2/node_modules/@smithy/node-http-handler/dist-cjs/index.js:150:3
at anonymous (native:1:1)
at /myproject/node_modules/.pnpm/require-in-the-middle@7.3.0/node_modules/require-in-the-middle/index.js:295:32
at /myproject/node_modules/.pnpm/@smithy+util-stream@3.0.6/node_modules/@smithy/util-stream/dist-cjs/sdk-stream-mixin.js:4:1
Reacted by Benyam Ephrem, Harsh Vakharia, Banks Nussman, Ev Haus, Pukima, Ian Pascoe, Kravets, Kane Wang, Mazen Besher and Mark Peter Fejes
Reacted by Pukima and Mark Peter Fejes
Metadata
Metadata
Assignees
Labels
BugBunExternal DependencyTo close this issue, an external dependency needs to be adjusted/fixedTo close this issue, an external dependency needs to be adjusted/fixedState: Blocked
Projects
- StatusShow more project fieldsNo status
Activity
chargome commentedon Jul 12, 2024
@EvHaus thanks for reaching out. I could set up a small repo and use node-file-router without any issues. Are you using any auto-instrumentation e.g. for express? Also could you provide the output when you add
debug: trueto yourinitcall? Anything that could help me reproduce your error would be helpful!EvHaus commentedon Jul 13, 2024
Thanks for the quick response @chargome. Looks like I was missing one crucial element. Seems like it's an issue with
@aws-sdk/client-s3. Simply importing from there causes the error.The full repro is as follows:
Then run the app via
bun index.ts.andreiborza commentedon Jul 15, 2024
Hello, this seems to be an issue upstream with opentelemetry and shimmer. I'm afraid there's not much we can do right now, but we're looking into that.
To get you unstuck, you could set up a manual client and drop the http integration. This way you'll at least have error tracking and basic performance data (if you use
Bun.serve), but you won't get opentelemetry instrumentation, for example db integrations.Hope this helps!
50 remaining items
msonnb commentedon Sep 29, 2026
If anyone is still affected by this, our Bun support has improved a lot in our newest major version (v11) since we moved away from using OpenTelemetry under the hood to tracing-channel based instrumentation. Here are our current docs for Bun: https://docs.sentry.io/platforms/javascript/guides/bun/
Feel free to try it out and to open a new issue if something's not working for you. Thanks for the patience!