From 71ce7c3415d2714b29ab9016a072082965bc802e Mon Sep 17 00:00:00 2001 From: Daniel Philip Johnson Date: Fri, 17 Jan 2025 14:13:26 +0000 Subject: [PATCH] fix(error): reorder error handling logic to respect handled flag Move HTML generation after event.handled check to prevent unnecessary error page generation for already handled errors. --- packages/nuxt/src/core/runtime/nitro/error.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/core/runtime/nitro/error.ts b/packages/nuxt/src/core/runtime/nitro/error.ts index 67e8f4acaa..57fcfd8283 100644 --- a/packages/nuxt/src/core/runtime/nitro/error.ts +++ b/packages/nuxt/src/core/runtime/nitro/error.ts @@ -80,7 +80,10 @@ export default async function errorhandler (error: H3Error, return send(event, template(errorObject)) } + if (event.handled) { return } + const html = await youch.toHTML(error, { + title: `${errorObject.statusCode}`, request: { url, method: event.method, @@ -88,8 +91,6 @@ export default async function errorhandler (error: H3Error, }, }) - if (event.handled) { return } - for (const [header, value] of res.headers.entries()) { setResponseHeader(event, header, value) }