diff --git a/packages/node/src/integrations/http/SentryHttpInstrumentation.ts b/packages/node/src/integrations/http/SentryHttpInstrumentation.ts index 3db9df73a196..aa1f0157f2cf 100644 --- a/packages/node/src/integrations/http/SentryHttpInstrumentation.ts +++ b/packages/node/src/integrations/http/SentryHttpInstrumentation.ts @@ -154,17 +154,17 @@ export class SentryHttpInstrumentation extends InstrumentationBase boolean, ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => { - return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean { + return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean { // Only traces request events - if (event !== 'request') { - return original.apply(this, [event, ...args]); + if (args[0] !== 'request') { + return original.apply(this, args); } instrumentation._diag.debug('http instrumentation for incoming request'); const isolationScope = getIsolationScope().clone(); - const request = args[0] as http.IncomingMessage; - const response = args[1] as http.OutgoingMessage; + const request = args[1] as http.IncomingMessage; + const response = args[2] as http.OutgoingMessage; const normalizedRequest = httpRequestToRequestData(request); @@ -202,12 +202,12 @@ export class SentryHttpInstrumentation extends InstrumentationBase { - return original.apply(this, [event, ...args]); + return original.apply(this, args); }); }); }; diff --git a/packages/node/src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts b/packages/node/src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts index 335f23604e10..e98256211f84 100644 --- a/packages/node/src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts +++ b/packages/node/src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts @@ -51,17 +51,17 @@ export class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase { return ( original: (event: string, ...args: unknown[]) => boolean, ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => { - return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean { + return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean { // Only traces request events - if (event !== 'request') { - return original.apply(this, [event, ...args]); + if (args[0] !== 'request') { + return original.apply(this, args); } const response = args[1] as http.OutgoingMessage; patchResponseToFlushOnServerlessPlatforms(response); - return original.apply(this, [event, ...args]); + return original.apply(this, args); }; }; }