unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

Missing afterReponse hook when an error happens #2560

Open huang-julien opened 3 months ago

huang-julien commented 3 months ago

Environment

windows 11 nitro 2.9.6 h3 1.11 - 1.12

Reproduction

https://stackblitz.com/edit/unjs-nitro-starter-bbtnhb?file=server%2Froutes%2Fthrow.ts,server%2Froutes%2Findex.ts,server%2Fplugins%2Flog.ts,package.json&title=Nitro%20Starter

index return an error and /throw throws an error. In both case, afterResponse isn't called

Describe the bug

There's a bug where throwing error in handlers prevent the afterResponse from being called.

Additional context

No response

Logs

No response

huang-julien commented 3 months ago

Upstream issue from https://github.com/unjs/h3/issues/790