Skip to content

Commit 3367dfe

Browse files
tombruijnunflxwluismiramirez
committed
Fix Express error handler signature error
Fixed an error thrown when using the Express error handler that depended on which types package version for Express is used. We've tried to fix the types but couldn't get to make it work due to how the interfaces in `@types/express-serve-static-core` are. We tried to replicate the exact same types allowed in the `IRouterHandler` interface without any success. The return type of the error handler cannot be an `ExpressErrorHandler` anymore as it doesn't comply with the latest types defined by the packages. This commit removes the return type of the error handler and makes the `req` and `res` argument to be of `any` type to stop the error from happening and to hopefully keep the handler compatible in future possible patches of the types packages. Co-authored-by: Noemi Lapresta <[email protected]> Co-authored-by: Luismi Ramirez <[email protected]>
1 parent f38895a commit 3367dfe

File tree

4 files changed

+78
-24
lines changed

4 files changed

+78
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
bump: "patch"
3+
type: "fix"
4+
---
5+
6+
Fix a TypeScript types compatibility error upon app compilation when using the AppSignal Express error handler.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/instrumentation/express/error_handler.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Request, Response, NextFunction, ErrorRequestHandler } from "express"
1+
import { NextFunction } from "express"
22
import { setError } from "../../helpers"
33

4-
export function expressErrorHandler(): ErrorRequestHandler {
4+
export function expressErrorHandler() {
55
return function (
66
err: Error & { status?: number },
7-
req: Request,
8-
res: Response,
7+
req: any,
8+
res: any,
99
next: NextFunction
1010
) {
1111
if (!err.status || err.status >= 500) {

test/express-redis/app/package-lock.json

+66-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)