-
Notifications
You must be signed in to change notification settings - Fork 397
Open
Labels
status: needs triageIssues which needs to be reproduced to be verified report.Issues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.Issues describing a broken feature.
Description
Description
When attempting to use express-session for session management (with the intention of making use of the @Session decorator) Errors thrown within routes are no longer being handled by the default error handler. In the code snippet below when I remove express-session the error gets returned correctly to the caller, but with the session configured the node process crashes with the throw HTTPError.
As an aside I would say there's very little documentation on how I'm supposed to configure sessions with Routing-controllers, so there's a reasonable chance this isn't the intended/supported way. Given the mention of express-session in the documentation I assume this is the supported express session manager!
Minimal code-snippet showcasing the problem
import express from "express";
import session from "express-session";
import {
Get,
HttpError,
JsonController,
useExpressServer,
} from "routing-controllers";
@JsonController()
class MainController {
@Get("/")
get() {
throw new HttpError(500, "whoops");
}
// Curiously when the controller has only one route this issue
// doesn't occur
@Get("/another")
getAnother() {
return "another";
}
}
const app = express();
// Commenting out this block makes it work again
app.use(
session({
secret: "23ruhiw",
resave: true,
saveUninitialized: true,
})
);
useExpressServer(app, {
controllers: [MainController],
});
app.listen(5000);Expected behavior
- Call the endpoint hosted on
/ - Receive JSON response:
{
"name": "HttpError",
"message": "whoops",
"stack": "Error: \n at new HttpError..."
}Actual behavior
- Call the endpoint hosted on
/ - Node crashes with a series of the HTTPError objects logged to the console (10 times to be specific)
Metadata
Metadata
Assignees
Labels
status: needs triageIssues which needs to be reproduced to be verified report.Issues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.Issues describing a broken feature.