-
-
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] 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 |
As I mentioned, I tried that as well, and it does not worked.
…On Fri, Dec 13, 2024, 00:15 Francesco Gringl-Novy ***@***.***> wrote:
Your example looks different from the docs you linked - you have import
'./instrument' on the top of your file, instead of running this in
--import? Instrumentation sadly cannot work in this scenario, you have to
do e.g. node --import ./instrument.mjs ./index.mjs for instrumentation to
work, as described in
https://docs.sentry.io/platforms/javascript/guides/node/install/esm/.
—
Reply to this email directly, view it on GitHub
<#12056 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ2T6ANQVJZSUPPAMXQBGMD2FKJSTAVCNFSM6AAAAABHYT75LCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBQHA2DAMBZGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Sorry, there are a lot of messages in this issue, it can be hard to keep track of what belongs where. What I would ask of you is:
|
Okay so I am also getting the same issue.
Console Code
Logs:
|
@ritvick I'm not seeing any logs that Also, which version of Express are you using? |
Also having this issue.
instrument.js:
webserver.js:
server output:
One thing I noticed in the sentry debug logs is that it says "Running in CommonJS mode." when I'm using ESM.. That output is from starting it via I have also run it via Node version 18. Thanks! |
@OakBehringer if you remove the |
I created a reproduction in https://github.com/vluoto/express-v5-sentry. See the README for details and reproduction steps.
It doesn't (see the above reproduction). |
We do not support express v5 yet, sadly. You can follow progress on this here: #13674 So basically, on express v5 you will not get express-specific (e.g. middleware, ...) spans. General HTTP instrumentation will still work, in a limited way, and error monitoring should also way. For the time being, you can opt-out of warnings via |
I see, thanks! I made a copy of https://github.com/vluoto/express-v5-sentry, replaced express v5 with v4, and made it available in https://github.com/vluoto/express-v4-sentry. There's a warning with |
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: