-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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/nestjs
SDK Version
9.40.0
Framework Version
Nest 10.0.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
Steps to Reproduce
I have been unable to produce a minimal reproduction. This error never occured until we introduced Sentry, and the error also disappears if we comment the Sentry.init()
in the project. I realize that's not very helpful, and would be happy to provide additional details given your guidance.
Anyway, this is what we experience on our end:
With the default Sentry integrations enabled (set up following the official docs), endpoints of certain content types (e.g. application/x-www-form-urlencoded
) fail with stream is not readable
:
➜ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" http://localhost:4000/api/foo "foo=bar"
{"statusCode":500,"message":"stream is not readable"}%
(See stacktrace under Actual Result
).
This error does not get recorded by Sentry.
application/json
requests, however, are fine.
➜ curl -X POST -H "Content-Type: application/json" http://localhost:4000/api/foo -d '{}'
{"message":"Missing Mailgun signature","error":"Unauthorized","statusCode":401}%
(This specific error is expected for my test request)
Seeing how there was a reference to @opentelemetry/instrumentation-express
in the stack trace, I did some additional research where I found that disabling the Express integration will fix also the issue (while leaving Sentry and other integrations intact).
Sentry.init({
dsn: process.env.SENTRY_ENDPOINT,
environment: process.env.SENTRY_ENVIRONMENT,
release: process.env.SENTRY_RELEASE,
tracesSampleRate: 1.0,
_experiments: { enableLogs: true },
integrations: (defaults) => {
return [
// The below resolves the issue
...defaults.filter((i) => i.name !== 'Express')
];
},
})
Expected Result
Would expect requests not to crash.
Actual Result
ERROR [ExceptionsHandler] stream is not readable - {
stack: [
'InternalServerError: stream is not readable\n' +
' at readStream (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/raw-body/index.js:185:17)\n' +
' at getRawBody (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/raw-body/index.js:116:12)\n' +
' at read (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/read.js:79:3)\n' +
' at urlencodedParser (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/types/urlencoded.js:116:5)\n' +
' at patched (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation-express/src/instrumentation.ts:286:27)\n' +
' at Layer.handle [as handle_request] (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)\n' +
' at trim_prefix (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)\n' +
' at /Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:286:9\n' +
' at Function.process_params (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:346:12)\n' +
' at next (/Users/hognevevle/Projects/myproject/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:280:10)'
]
}
Metadata
Metadata
Assignees
Type
Projects
Status