Trowing error in async/await route times out when using async handler
See original GitHub issueSo I’m not sure I am doing everything correctly here. But how come throwing an Error in this case causes the lambda to timeout?
How can I prevent the lambda from timing out?
import express from 'express';
import awsServerlessExpress from 'aws-serverless-express';
const app = express();
app.get('/throwerror', async (req, res) => {
throw new Error('This is an error');
});
const server = awsServerlessExpress.createServer(app);
export const handler = async (event: any, context: any) => awsServerlessExpress.proxy(server, event, context, 'PROMISE').promise;
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Trowing error in async/await route times out when using ...
So I'm not sure I am doing everything correctly here. But how come throwing an Error in this case causes the lambda to...
Read more >express.js async router and error handling
I use following approach: Create asyncWrap as helper middleware: const asyncWrap = fn => function asyncUtilWrap (req, res, next, ...
Read more >Async Error Handling in Node.js + Express | by Nate Jones
If synchronous code throws an error, then Express will catch and process it." But, for async: "For errors returned from asynchronous functions ...
Read more >Error handling with Async/Await in JS | by Ian Segers
This works as expected, we call the function thisThrows() which throws a regular error, we catch it, log the error and optionally we...
Read more >Using async/await in Express
The easiest way to use async/await in Express is use express-async-handler. This article shows you why, and how you can use it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Removing async is not an option since I have asyncronious calls to the database. Using https://github.com/Abazhenov/express-async-handler workes though.
The reson why I created this bug was because I thought it was a bit extreme for the lambda to time out on a async error. But I guess it is not up to aws-serverless-express to take care of that.
Thanks for the comment. This sounds like a bug. I’ll fix and release as soon as I can