2 ms·
> async middleware not handling errors properly thing though Can you expand on this? Error handling in middleware is pretty well documented.
by contextnavidad 3y ago
> async middleware not handling errors properly thing though
Can you expand on this? Error handling in middleware is pretty well documented.
- roblh 3y agoAnytime an error happens inside an async middleware in express, you have to explicitly catch it and pass it directly to the `next` function, otherwise it'll just disappear and any kind of error logging middleware you have later on will never see it. In synchronous functions any error is passed automatically. You can write more middleware to address this, or just manually catch everything, but it just means more boilerplate. There's no reason to expect different types of middleware to have different behaviour unless you already know. It's not catastrophic, but I expect more consistent design from such an established library, especially considering how long this has been an issue.