UNPKG

@nuxt/nitro-server

Version:

Nitro server integration for Nuxt

51 lines (50 loc) 2.31 kB
import { createConsoleReporter, defineDiagnostics } from "nostics"; import { ansiFormatter } from "nostics/formatters/ansi"; //#region src/runtime/diagnostics.ts const ansi = (open, close) => (s) => `\x1B[${open}m${s}\x1B[${close}m`; const colors = { red: ansi(31, 39), yellow: ansi(33, 39), cyan: ansi(36, 39), gray: ansi(90, 39), bold: ansi(1, 22), dim: ansi(2, 22) }; /** * E8xxx * Nitro server runtime (SSR rendering / dev server) diagnostics. */ const docsBase = (code) => `https://nuxt.com/docs/4.x/errors/${code.replace("NUXT_", "").toLowerCase()}`; const serverDiagnostics = /* #__PURE__ */ defineDiagnostics({ docsBase, reporters: [/* @__PURE__ */ createConsoleReporter(import.meta.dev && process.env.NODE_ENV !== "test" ? { formatter: ansiFormatter(colors) } : void 0)], codes: { NUXT_E8001: { why: (p) => `\`render:html\` mutated \`body\`/\`bodyAppend\` while streaming (\`${p.path}\`). These fields are silently dropped because the body is about to stream.`, fix: "Use the `render:html:close` hook instead.", docs: false }, NUXT_E8002: { why: (p) => `SSR streaming committed the response before render completed (\`${p.path}\`). The following mutations did not reach the client and were dropped:\n - ${p.mutations}`, fix: (p) => `Move the mutation into a plugin (which runs before the shell is flushed), or opt this route out of streaming with \`routeRules: { '${p.path}': { streaming: false } }\` or the \`render:route\` hook.`, docs: false }, NUXT_E8003: { why: (p) => `Failed to stringify dev server logs.${p.error ? ` Received \`${p.error}\`.` : ""}`, fix: "You can define your own reducer/reviver for rich types following the instructions in `https://nuxt.com/docs/4.x/api/composables/use-nuxt-app#payload`.", docs: false }, NUXT_E8004: { why: "The server bundle is not available.", fix: "Ensure the Nuxt build completed successfully and the server entry was emitted by your builder.", docs: false }, NUXT_E8005: { why: "Island props cannot contain a `template` key, which the Vue runtime compiler would compile and execute.", fix: "Rename the prop (e.g. `templateName`), or disable `vue.runtimeCompiler` if you do not need runtime template compilation.", docs: false } } }); //#endregion export { serverDiagnostics };