-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@sentry/bun throws "TypeError: Cannot replace module namespace object's binding with configurable attribute" #12891
Comments
@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 |
Thanks for the quick response @chargome. Looks like I was missing one crucial element. Seems like it's an issue with The full repro is as follows: // index.ts
import { initFileRouter } from 'node-file-router';
import { init } from '@sentry/bun';
init({dsn: '__MY_DSN__'});
await initFileRouter(); // api/index.ts
import { DeleteObjectCommand } from '@aws-sdk/client-s3';
const index = () => {
console.log(DeleteObjectCommand);
};
export default index; Then run the app via |
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 import {
BunClient,
defaultStackParser,
getDefaultIntegrations,
makeFetchTransport,
setCurrentClient
} from '@sentry/bun'
const integrations = getDefaultIntegrations({}).filter((integration) => integration.name !== 'Http')
const client = new BunClient({
dsn: '__MY_DSN__',
stackParser: defaultStackParser,
transport: makeFetchTransport,
tracesSampleRate: 1.0,
integrations,
})
setCurrentClient(client)
client.init() Hope this helps! |
Dear @andreiborza I am currently facing the same
error. I was using @sentry/node bun after this issue, I have switched to @sentry/bun however, whenever I add the For reference: I am using Express with typescript and ESM syntax and this is the sentry debug output: Sentry Logger [log]: Initializing Sentry: process: 73610, thread: main.
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: NodeFetch
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: BunServer
Sentry Logger [log]: Running in CommonJS mode.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for diag v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for trace v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for context v1.9.0.
Sentry Logger [debug]: @opentelemetry/api: Registered a global for propagation v1.9.0.
[Sentry] express is not instrumented. This is likely because you required/imported express before calling `Sentry.init()`.
Server is listening on port 4001 I have also realized that sentry is running in CommonJS mode. Is this normal? If not, what can I do to fix that issue too? Thank you for your time, |
@Tunanika there is no need to preload the instrument file in You will still face the issue that Regarding capturing errors you could capture exceptions using a global error handler like this: function customErrorHandler(
err: Error,
_req: Request,
res: Response,
_next: NextFunction
) {
Sentry.captureException(err);
// handle your error response
res.status(500).send("sadness...");
}
app.use(customErrorHandler); Hope that helps you get going for now! |
Dear @chargome Thank you very much for your response. Yes sentry currently does capture any errors in express endpoints. However upon building the project 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 This is my import * as Sentry from "@sentry/bun";
// Ensure to call this before importing any other modules!
Sentry.init({
dsn: "dsn",
// Add Performance Monitoring by setting tracesSampleRate
// Set tracesSampleRate to 1.0 to capture 100% of transactions
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
}); Index.mts: import "./instrument.mjs";
import * as Sentry from "@sentry/bun";
import express from "express";
import cors from "cors";
import morgan from "Morgan";
import cookieParser from "cookie-parser";
import type { Request, Response, NextFunction } from "express";
.
.
.
Sentry.setupExpressErrorHandler(app); What can I do to fix the issue that it fails after building? |
Hm yeah that should not be the case, we're running into the same issue again this way.. Since you're not running this code in a browser would it be an option for you to just run your server using |
Yes I can keep running the server that way it's not a problem. Thank you for your response, good to know it's not a problem with my integration. |
@andreiborza not have a public repo but I think you can reproduce by installing using their docs (its simple) after this just add @sentry/bun and try to init it with Sentry.init. It gives error on init. I overcome the situation by disabling Http integration and switching to @sentry/node instead of Bun. Also I had another error says startTransaction function is undefined . I fix it by changing the @sentry/node's version to same as @sentry/tracing (v7.114.0). Same error happens in @sentry/bun also and changing version didn't help. |
Thanks, we will take a look. |
Facing this same issue on v |
Hey thanks for chiming in. We're still looking into this a bit closer but are currently on limited support due to a company-wide hackweek. We'll get back to our regular support next week. |
@andreiborza I am experiencing the same issue in bun when I preload sentry.ts with the init config |
@Jonatthu @bephrem1 we're aware of this, there is is an open upstream issue for that: oven-sh/bun#13165 |
If anyone is looking for a fix that is a little closer to the standard implementation, you can do: import * as Sentry from '@sentry/bun';
Sentry.init({
dsn: 'YOUR_DSN',
// TODO: Issue with standard instrumentation:
// https://github.com/getsentry/sentry-javascript/issues/12891
// https://github.com/oven-sh/bun/issues/13165
defaultIntegrations: Sentry.getDefaultIntegrations({}).filter((i) => i.name !== 'Http'),
tracesSampleRate: 1.0,
}); |
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.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
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 theinit()
call causes issues. My code for that is:Expected Result
No failure
Actual Result
App crashes with:
The text was updated successfully, but these errors were encountered: