Skip to content

Commit a5821ce

Browse files
committed
PR feedback
1 parent 732b7da commit a5821ce

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

packages/core/src/integrations/requestdata.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
8484
const ipAddress = request ? request.ip || (request.socket && request.socket.remoteAddress) : undefined;
8585
const user = request ? request.user : undefined;
8686

87-
return addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress, user }, addRequestDataOptions);
87+
addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress, user }, addRequestDataOptions);
88+
return event;
8889
}
8990

9091
if (!request) {

packages/node/src/integrations/http.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ export const instrumentHttp = Object.assign(
175175
patchRequestToCaptureBody(req, normalizedRequest);
176176

177177
// Update the isolation scope, isolate this request
178-
isolationScope.setSDKProcessingMetadata({ normalizedRequest });
179-
isolationScope.setSDKProcessingMetadata({ request: req });
178+
isolationScope.setSDKProcessingMetadata({ request: req, normalizedRequest });
180179

181180
const client = getClient<NodeClient>();
182181
if (client && client.getOptions().autoSessionTracking) {
@@ -353,7 +352,7 @@ function patchRequestToCaptureBody(req: HTTPModuleRequestIncomingMessage, normal
353352
// eslint-disable-next-line @typescript-eslint/unbound-method
354353
req.on = new Proxy(req.on, {
355354
apply: (target, thisArg, args: Parameters<typeof req.on>) => {
356-
const [event, listener] = args;
355+
const [event, listener, ...restArgs] = args;
357356

358357
if (event === 'data') {
359358
const callback = new Proxy(listener, {
@@ -366,7 +365,7 @@ function patchRequestToCaptureBody(req: HTTPModuleRequestIncomingMessage, normal
366365

367366
callbackMap.set(listener, callback);
368367

369-
return Reflect.apply(target, thisArg, [event, callback]);
368+
return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);
370369
}
371370

372371
if (event === 'end') {
@@ -389,7 +388,7 @@ function patchRequestToCaptureBody(req: HTTPModuleRequestIncomingMessage, normal
389388

390389
callbackMap.set(listener, callback);
391390

392-
return Reflect.apply(target, thisArg, [event, callback]);
391+
return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);
393392
}
394393

395394
return Reflect.apply(target, thisArg, args);

packages/utils/src/requestdata.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,15 @@ export function extractRequestData(
268268

269269
/**
270270
* Add already normalized request data to an event.
271+
* This mutates the passed in event.
271272
*/
272273
export function addNormalizedRequestDataToEvent(
273274
event: Event,
274275
req: Request,
275276
// This is non-standard data that is not part of the regular HTTP request
276277
additionalData: { ipAddress?: string; user?: Record<string, unknown> },
277278
options: AddRequestDataToEventOptions,
278-
): Event {
279+
): void {
279280
const include = {
280281
...DEFAULT_INCLUDES,
281282
...(options && options.include),
@@ -318,8 +319,6 @@ export function addNormalizedRequestDataToEvent(
318319
};
319320
}
320321
}
321-
322-
return event;
323322
}
324323

325324
/**

0 commit comments

Comments
 (0)