mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nitro): ensure ssr error statusCode
is a number (#19001)
This commit is contained in:
parent
54739e435e
commit
859fbd0add
@ -85,7 +85,7 @@ interface _NuxtApp {
|
|||||||
rendered?: Function
|
rendered?: Function
|
||||||
error?: Error | {
|
error?: Error | {
|
||||||
url: string
|
url: string
|
||||||
statusCode: string
|
statusCode: number
|
||||||
statusMessage: string
|
statusMessage: string
|
||||||
message: string
|
message: string
|
||||||
description: string
|
description: string
|
||||||
|
@ -167,8 +167,13 @@ export default defineRenderHandler(async (event) => {
|
|||||||
|
|
||||||
// Whether we're rendering an error page
|
// Whether we're rendering an error page
|
||||||
const ssrError = event.node.req.url?.startsWith('/__nuxt_error')
|
const ssrError = event.node.req.url?.startsWith('/__nuxt_error')
|
||||||
? getQuery(event) as Exclude<NuxtApp['payload']['error'], Error>
|
? getQuery(event) as unknown as Exclude<NuxtApp['payload']['error'], Error>
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
if (ssrError && ssrError.statusCode) {
|
||||||
|
ssrError.statusCode = parseInt(ssrError.statusCode as any)
|
||||||
|
}
|
||||||
|
|
||||||
if (ssrError && event.node.req.socket.readyState !== 'readOnly' /* direct request */) {
|
if (ssrError && event.node.req.socket.readyState !== 'readOnly' /* direct request */) {
|
||||||
throw createError('Cannot directly render error page!')
|
throw createError('Cannot directly render error page!')
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ describe.skipIf(isWindows)('minimal nuxt application', () => {
|
|||||||
|
|
||||||
it('default server bundle size', async () => {
|
it('default server bundle size', async () => {
|
||||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||||
expect(stats.server.totalBytes).toBeLessThan(90000)
|
expect(stats.server.totalBytes).toBeLessThan(90200)
|
||||||
|
|
||||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||||
expect(modules.totalBytes).toBeLessThan(2700000)
|
expect(modules.totalBytes).toBeLessThan(2700000)
|
||||||
|
Loading…
Reference in New Issue
Block a user