-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working properly when using with multer upload #46
Comments
Same ! I struggled 2 days to make sense of the problem ! The culprit was this package . While uploading a file , if you go and check If the file was uploaded or not ... there is a resulting unhandled promise rejection and the whole server crashes |
@junioroo Well , I tried a few more packages to handle async errors , but unfortunately , they too could not catch the async errors thrown by multer . So , well I went ahead and added
|
This is not just for multer, just tested and its when an inner function throws an unhandled rejection. app.get('/async', async (req: Request, res: Response) => {
async function test() {
throw new Error('ASYNC test;' + Date.now());
}
test();
}); Crashes the app. Interestingly, adding I would think the easiest workaround is to not use nesting and use a cleaner syntax anyways (await). Instead of using the callback, see if you can use await |
I've changed one of the tests to match the same approach I'm using in my application but it's not being handled:
When I execute the test, I'm only receiving the crash "error" in the terminal, not the expected status from the handler!
Thanks for the help
The text was updated successfully, but these errors were encountered: