Skip to content

Commit

Permalink
fix(node): Safely create requests (#10285)
Browse files Browse the repository at this point in the history
* fix(node): Wrap request creation in try catch

* chore: changeset
  • Loading branch information
Princesseuh authored Mar 1, 2024
1 parent fea77cf commit 0781eb6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/integrations/node/src/serve-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import type { RequestHandler } from './types.js';
*/
export function createAppHandler(app: NodeApp): RequestHandler {
return async (req, res, next, locals) => {
const request = NodeApp.createRequest(req);
let request;
try {
request = NodeApp.createRequest(req);
} catch (err) {
res.statusCode = 500;
res.end('Internal Server Error');
return;
}

const routeData = app.match(request);
if (routeData) {
const response = await app.render(request, {
Expand Down

0 comments on commit 0781eb6

Please sign in to comment.