diff --git a/package.json b/package.json index 64b75fb875..4e80210dcf 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "execa": "7.1.1", "fs-extra": "11.1.1", "globby": "13.2.0", - "h3": "1.6.6", + "h3": "1.7.0", "jiti": "1.18.2", "markdownlint-cli": "^0.33.0", "nuxi": "workspace:*", diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index d0a76ea4bb..152b6eab19 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -36,7 +36,7 @@ "execa": "7.1.1", "flat": "5.0.2", "giget": "1.1.2", - "h3": "1.6.6", + "h3": "1.7.0", "jiti": "1.18.2", "listhen": "1.0.4", "mlly": "1.3.0", diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 25137efa5c..3f59c2aa1c 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -72,7 +72,7 @@ "estree-walker": "^3.0.3", "fs-extra": "^11.1.1", "globby": "^13.2.0", - "h3": "^1.6.6", + "h3": "^1.7.0", "hookable": "^5.5.3", "jiti": "^1.18.2", "klona": "^2.0.6", diff --git a/packages/nuxt/src/core/runtime/nitro/error.ts b/packages/nuxt/src/core/runtime/nitro/error.ts index 80ce8c8b1d..22d77781cd 100644 --- a/packages/nuxt/src/core/runtime/nitro/error.ts +++ b/packages/nuxt/src/core/runtime/nitro/error.ts @@ -21,9 +21,6 @@ export default async function errorhandler (error: H3Error, data: error.data } - // Set response code and message - setResponseStatus(event, (errorObject.statusCode !== 200 && errorObject.statusCode) as any as number || 500, errorObject.statusMessage) - // Console output if (error.unhandled || error.fatal) { const tags = [ @@ -36,6 +33,11 @@ export default async function errorhandler (error: H3Error, console.error(tags, errorObject.message + '\n' + stack.map(l => ' ' + l.text).join(' \n')) } + if (event.handled) { return } + + // Set response code and message + setResponseStatus(event, (errorObject.statusCode !== 200 && errorObject.statusCode) as any as number || 500, errorObject.statusMessage) + // JSON response if (isJsonRequest(event)) { setResponseHeader(event, 'Content-Type', 'application/json') @@ -63,16 +65,19 @@ export default async function errorhandler (error: H3Error, // TODO: Support `message` in template (errorObject as any).description = errorObject.message } + if (event.handled) { return } setResponseHeader(event, 'Content-Type', 'text/html;charset=UTF-8') event.node.res.end(template(errorObject)) return } + const html = await res.text() + if (event.handled) { return } + for (const [header, value] of res.headers.entries()) { setResponseHeader(event, header, value) } - setResponseStatus(event, res.status && res.status !== 200 ? res.status : undefined, res.statusText) - event.node.res.end(await res.text()) + event.node.res.end(html) } diff --git a/packages/schema/package.json b/packages/schema/package.json index 322656a7b0..1ec6484e3a 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -34,7 +34,7 @@ "@vitejs/plugin-vue": "4.2.3", "@vitejs/plugin-vue-jsx": "3.0.1", "esbuild-loader": "3.0.1", - "h3": "1.6.6", + "h3": "1.7.0", "ignore": "5.2.4", "nitropack": "2.4.1", "unbuild": "latest", diff --git a/packages/vite/package.json b/packages/vite/package.json index 220b51e579..f357da4389 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -40,7 +40,7 @@ "externality": "^1.0.2", "fs-extra": "^11.1.1", "get-port-please": "^3.0.1", - "h3": "^1.6.6", + "h3": "^1.7.0", "knitwork": "^1.0.0", "magic-string": "^0.30.0", "mlly": "^1.3.0", diff --git a/packages/webpack/package.json b/packages/webpack/package.json index e062477e82..19635001bf 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -31,7 +31,7 @@ "file-loader": "^6.2.0", "fork-ts-checker-webpack-plugin": "^8.0.0", "fs-extra": "^11.1.1", - "h3": "^1.6.6", + "h3": "^1.7.0", "hash-sum": "^2.0.0", "lodash-es": "^4.17.21", "magic-string": "^0.30.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2ab86f501..951394817b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,8 +81,8 @@ importers: specifier: 13.2.0 version: 13.2.0 h3: - specifier: 1.6.6 - version: 1.6.6 + specifier: 1.7.0 + version: 1.7.0 jiti: specifier: 1.18.2 version: 1.18.2 @@ -278,8 +278,8 @@ importers: specifier: 1.1.2 version: 1.1.2 h3: - specifier: 1.6.6 - version: 1.6.6 + specifier: 1.7.0 + version: 1.7.0 jiti: specifier: 1.18.2 version: 1.18.2 @@ -383,8 +383,8 @@ importers: specifier: ^13.2.0 version: 13.2.0 h3: - specifier: ^1.6.6 - version: 1.6.6 + specifier: ^1.7.0 + version: 1.7.0 hookable: specifier: ^5.5.3 version: 5.5.3 @@ -559,8 +559,8 @@ importers: specifier: 3.0.1 version: 3.0.1(webpack@5.87.0) h3: - specifier: 1.6.6 - version: 1.6.6 + specifier: 1.7.0 + version: 1.7.0 ignore: specifier: 5.2.4 version: 5.2.4 @@ -686,8 +686,8 @@ importers: specifier: ^3.0.1 version: 3.0.1 h3: - specifier: ^1.6.6 - version: 1.6.6 + specifier: ^1.7.0 + version: 1.7.0 knitwork: specifier: ^1.0.0 version: 1.0.0 @@ -801,8 +801,8 @@ importers: specifier: ^11.1.1 version: 11.1.1 h3: - specifier: ^1.6.6 - version: 1.6.6 + specifier: ^1.7.0 + version: 1.7.0 hash-sum: specifier: ^2.0.0 version: 2.0.0 @@ -5385,12 +5385,12 @@ packages: dependencies: duplexer: 0.1.2 - /h3@1.6.6: - resolution: {integrity: sha512-DWu2s11OuuO9suEkX99dXaJoxd1RgPXiM4iDmLdrhGV63GLoav13f3Kdd5/Rw7xNKzhzn2+F2dleQjG66SnMPQ==} + /h3@1.7.0: + resolution: {integrity: sha512-iJJz2Pn2rC0j8CB3rkFMs0K269W7hDVOC7eL3qne5Joy4JZX1W7id7PBFV593GboHDOx0PzgO6ocqsynrIvdxw==} dependencies: cookie-es: 1.0.0 defu: 6.1.2 - destr: 1.2.2 + destr: 2.0.0 iron-webcrypto: 0.7.0 radix3: 1.0.1 ufo: 1.1.2 @@ -6548,7 +6548,7 @@ packages: fs-extra: 11.1.1 globby: 13.2.0 gzip-size: 7.0.0 - h3: 1.6.6 + h3: 1.7.0 hookable: 5.5.3 http-proxy: 1.18.1 is-primitive: 3.0.1 @@ -8606,7 +8606,7 @@ packages: anymatch: 3.1.3 chokidar: 3.5.3 destr: 1.2.2 - h3: 1.6.6 + h3: 1.7.0 ioredis: 5.3.2 listhen: 1.0.4 lru-cache: 9.1.1 diff --git a/test/bundle.test.ts b/test/bundle.test.ts index a92b125df0..30eb83bf5c 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -35,10 +35,10 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM it('default server bundle size', async () => { stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir) - expect.soft(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.1k"') + expect.soft(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.2k"') const modules = await analyzeSizes('node_modules/**/*', serverDir) - expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2295k"') + expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2296k"') const packages = modules.files .filter(m => m.endsWith('package.json'))