mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +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
|
||||
error?: Error | {
|
||||
url: string
|
||||
statusCode: string
|
||||
statusCode: number
|
||||
statusMessage: string
|
||||
message: string
|
||||
description: string
|
||||
|
@ -167,8 +167,13 @@ export default defineRenderHandler(async (event) => {
|
||||
|
||||
// Whether we're rendering an error page
|
||||
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
|
||||
|
||||
if (ssrError && ssrError.statusCode) {
|
||||
ssrError.statusCode = parseInt(ssrError.statusCode as any)
|
||||
}
|
||||
|
||||
if (ssrError && event.node.req.socket.readyState !== 'readOnly' /* direct request */) {
|
||||
throw createError('Cannot directly render error page!')
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ describe.skipIf(isWindows)('minimal nuxt application', () => {
|
||||
|
||||
it('default server bundle size', async () => {
|
||||
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)
|
||||
expect(modules.totalBytes).toBeLessThan(2700000)
|
||||
|
Loading…
Reference in New Issue
Block a user