Skip to content

Commit 4300607

Browse files
committed
fix: Make handlers types compatibile with Express
1 parent 8e11393 commit 4300607

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [browser] test: Add loader + integration tests
1212
- [core] ref: Move SDKInformation integration into core prepareEvent method
1313
- [core] ref: Move debug initialization as the first step
14+
- [node] fix: Make handlers types compatibile with Express
1415

1516
## 4.0.4
1617

packages/node/src/handlers.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ function parseRequest(
136136
}
137137

138138
/** JSDoc */
139-
export function requestHandler(): (req: http.ClientRequest, res: http.ServerResponse, next: () => void) => void {
140-
return function sentryRequestMiddleware(req: http.ClientRequest, _res: http.ServerResponse, next: () => void): void {
139+
export function requestHandler(): (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void {
140+
return function sentryRequestMiddleware(
141+
req: http.IncomingMessage,
142+
_res: http.ServerResponse,
143+
next: () => void,
144+
): void {
141145
const local = domain.create();
142146
const hub = getHubFromCarrier(req);
143147
hub.bindClient(getCurrentHub().getClient());
@@ -169,13 +173,13 @@ function getStatusCodeFromResponse(error: MiddlewareError): number {
169173
/** JSDoc */
170174
export function errorHandler(): (
171175
error: MiddlewareError,
172-
req: http.ClientRequest,
176+
req: http.IncomingMessage,
173177
res: http.ServerResponse,
174178
next: (error: MiddlewareError) => void,
175179
) => void {
176180
return function sentryErrorMiddleware(
177181
error: MiddlewareError,
178-
req: http.ClientRequest,
182+
req: http.IncomingMessage,
179183
_res: http.ServerResponse,
180184
next: (error: MiddlewareError) => void,
181185
): void {

packages/node/src/integrations/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function loadWrapper(nativeModule: any): any {
8181
// just get that reference updated to use our new ClientRequest
8282
fill(originalModule, 'request', function(): any {
8383
return function(options: http.ClientRequestArgs, callback: () => void): any {
84-
return new originalModule.ClientRequest(options, callback) as http.ClientRequest;
84+
return new originalModule.ClientRequest(options, callback) as http.IncomingMessage;
8585
};
8686
});
8787

0 commit comments

Comments
 (0)