You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I return an error in eventHandler's using createError, global hooks onBeforeResponse and onAfterResponse behave unexpectedly:
onBeforeResponse always returns res.statusCode equal to 200
onAfterResponse does not work in case of an error in the handler
This does not track the actual status codes that users may encounter. For example, in my app I cannot collect statistics in Prometheus metrics.
exportconstapp=createApp({onBeforeResponse: (event)=>{// will always be 200console.log('[beforeResponse]',event.node.res.statusCode);},onAfterResponse: (event)=>{// not calledconsole.log('[afterResponse]',event.node.res.statusCode);},});constrouter=createRouter();app.use(router);router.get('/',eventHandler((event)=>{returncreateError({statusCode: 404});}));
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
Reproduction
See https://stackblitz.com/edit/github-d9z5tl?file=app.ts
Describe the bug
Forwarded from nuxt/nuxt#27248
When I return an error in
eventHandler
's usingcreateError
, global hooksonBeforeResponse
andonAfterResponse
behave unexpectedly:onBeforeResponse
always returnsres.statusCode
equal to 200onAfterResponse
does not work in case of an error in the handlerThis does not track the actual status codes that users may encounter. For example, in my app I cannot collect statistics in Prometheus metrics.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: