-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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] Express is not instrumented. This is likely because you required/imported express before calling Sentry.init()
#12056
Comments
Strange... I did some code refactoring, and didn't touch this part I shared at all.. somehow I'm not having this error anymore. I will close this issue for a bit, if I encounter it again, I'll reopen it |
Isse came back again, I have no idea why. I didn't change anything. tried to update to latest Sentry, didn't help. Tried to nuke node_modules. lock file and everything, still didn't work. This is some weird mystery... |
Hi there, Things changed in v8 a bit, most integrations are now automatically added and you no longer have to take care of those (with the exception of We recommend going through the migration guide here. You can use In your particular example, could you try removing |
hey, thanks for getting back @andreiborza! I did follow the migration guide, and used As you suggested, i removed |
If it helps, you may check my comment on another similar issue that was opened 2 days ago: |
If that help,s we can have a short screensharing call so u can get the context you need |
Have you updated to Could you please provide
I see a |
yes, updated just yesterday. And yes, same result.
Regarding bundler: I'm using @nx/esbuild, as it comes as built-in bundler in NX. Here is part of my NX project (this microservice) config: {
"name": "auth-service",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/auth-service/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{projectRoot}/build"],
"defaultConfiguration": "production",
"options": {
"platform": "node",
"outputPath": "{projectRoot}/build",
"format": ["cjs"],
"bundle": true,
"main": "apps/auth-service/src/main.ts",
"tsConfig": "apps/auth-service/tsconfig.app.json",
"assets": ["apps/auth-service/src/assets"],
"generatePackageJson": true,
"esbuildOptions": {
"sourcemap": true,
"outExtension": {
".js": ".js"
}
}
},
"configurations": {
"development": {},
"production": {
"generateLockfile": true,
"esbuildOptions": {
"sourcemap": false,
"outExtension": {
".js": ".js"
}
}
}
}
}, |
I figured why I stopped having this issue at that time, I removed sentry.setupExpressErrorHandler(app), that's why I didn't get that message. But the problem was still there, although I didn't see it in the console. So this issue is persistent |
So you should def. not remove the error handler :D Do you know if your app is being run as a CommonJS or ESM app? Basically, if you look into your build/dist folder, are the files in there using |
it's CJS, for sure :) |
could you please post snippets of |
Hi, I'm also seeing:
in my application logs despite following the sentry onboarding guide for express apps. Errors are still sent to sentry and everything seems to work fine though. Here's the code that I'm running: |
Are you not using performance? This is a bug in the current version, that it will show this warning if performance is disabled - it's safe to ignore it! In 8.3.0 (which should be out soon) this warning will be fixed/removed. |
Hey @Nabil372, thank you for providing a sample project. I've had a quick look over it, you do have performance (tracing) enabled so that's not the issue. I see that you're using esbuild with the output format ESM. For ESM, you need to I tried that out for you, but your build output doesn't seem to be pure ESM either—I'm seeing this snippet in the output which probably throws off internals of sentry/opentelemetry. |
@andreiborza Thanks for taking a look! I've implemented what you've suggested and I'm no longer seeing the warning message. |
@amiranvarov could you please update to the latest SDK? Should be |
@cyrus-za just to make sure, |
Side note, If you enable |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.0.0
Framework Version
express@^4.18.1, @nx/express": "18.2.2
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
I did right as you suggested it in your docs. Imprted and initialised Sentry first thing first. But still, it's not working
Expected Result
Do not have [Sentry] Express is not instrumented. This is likely because you required/imported express before calling
Sentry.init()
message, andActual Result
Having error message: [Sentry] Express is not instrumented. This is likely because you required/imported express before calling
Sentry.init()
message, andThe text was updated successfully, but these errors were encountered: