-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Add maxRequestBodySize
#16225
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
base: develop
Are you sure you want to change the base?
Conversation
560976f
to
7a21af7
Compare
size-limit report 📦
|
* | ||
* @default 'medium' | ||
*/ | ||
maxRequestBodySize?: 'none' | 'small' | 'medium' | 'always'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we rename this to maxIncomingRequestBodySize
? It is not clear right now that this only applies to incoming requests, not outgoing ones 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the name from the general Sentry docs: https://develop.sentry.dev/sdk/expected-features/#attaching-request-body-in-server-sdks
To be uniform with other SDKs, it would be beneficial to keep the name, but I agree that it would be clearer with incoming
. At least, the information is available in the JSDoc 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to have the same name, if we think something else is better :) maybe you could also check with other sdk folks, if this also applies to outgoing requests in other implementations or just to incoming?
function patchRequestToCaptureBody( | ||
req: http.IncomingMessage, | ||
isolationScope: Scope, | ||
maxRequestBodySize: 'none' | 'small' | 'medium' | 'always', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: We could actually type this to omit none
as allowed value, and then avoid the further check in here, as we actually guard agains this already before calling this?
try { | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
req.on = new Proxy(req.on, { | ||
apply: (target, thisArg, args: Parameters<typeof req.on>) => { | ||
const [event, listener, ...restArgs] = args; | ||
|
||
if (event === 'data') { | ||
DEBUG_BUILD && logger.log(INSTRUMENTATION_NAME, 'Handling request.on("data")'); | ||
if (DEBUG_BUILD) { | ||
logger.log(INSTRUMENTATION_NAME, 'Handling request.on("data")'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Let's combine these into a single log line, e.g. Handling request.on("data") with maximum request body size ...
Adds
maxRequestBodySize
to the NodehttpIntegration
.The setting controls the maximum size of HTTP request bodies attached to events.
Available options:
closes #16179