fix: avoid crashing the Node.js app on uncaught exceptions (#307)

* fix: avoid crashing the Node.js app on uncaught exceptions

* Create smooth-dodos-obey.md

---------

Co-authored-by: Eric Allam <eallam@icloud.com>
This commit is contained in:
Liran Tal
2023-08-11 16:18:31 +03:00
committed by GitHub
parent 9dd7fb2748
commit 7daa82fc7a
2 changed files with 16 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/express": patch
---
fix: avoid crashing the Node.js app on uncaught exceptions
+3
View File
@@ -66,6 +66,7 @@ export function createMiddleware(client: TriggerClient, path: string = "/api/tri
return; return;
} }
try {
const request = convertToStandardRequest(req); const request = convertToStandardRequest(req);
const response = await client.handleRequest(request); const response = await client.handleRequest(request);
@@ -77,6 +78,8 @@ export function createMiddleware(client: TriggerClient, path: string = "/api/tri
} }
res.status(response.status).json(response.body); res.status(response.status).json(response.body);
} catch (error) {
next(error)
}; };
} }