{"record":{"id":"b9ef070df970805d","repo":"withastro/astro","slug":"nomanifestavailableerror","errorCode":"NoManifestAvailableError","errorMessage":"`new FetchState(request)` was called outside of an Astro server, so no manifest is available.","messagePattern":"`new FetchState\\(request\\)` was called outside of an Astro server, so no manifest is available\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/manifest/ambient.ts","lineNumber":36,"sourceCode":"/**\n * Registers a manifest for environments where `virtual:astro:manifest` cannot\n * resolve (plain Node: unit tests, embedders). Internal API — deliberately not\n * exported from any public entrypoint.\n * Pass `undefined` to clear (test teardown).\n */\nexport function setAmbientManifest(manifest: SSRManifest | undefined): void {\n\tregistered = manifest;\n}\n\n/**\n * The ambient manifest: the explicitly registered one, else the virtual\n * module's. Throws lazily when neither is available, so merely importing a\n * module that uses this never fails — only actually handling a request does.\n */\nexport function getAmbientManifest(): SSRManifest {\n\tconst manifest = registered ?? viteManifest;\n\tif (!manifest) {\n\t\tthrow new AstroError(NoManifestAvailable);\n\t}\n\treturn manifest;\n}\n\n/** The ambient manifest if one is available, else `undefined`. Never throws. */\nexport function tryGetAmbientManifest(): SSRManifest | undefined {\n\treturn registered ?? viteManifest;\n}\n","sourceCodeStart":18,"sourceCodeEnd":45,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/manifest/ambient.ts#L18-L45","documentation":"The public `new FetchState(request)` (astro/fetch) resolves static, build-time data via getAmbientManifest(): the manifest explicitly registered with setAmbientManifest, else the virtual manifest module bundled into every Astro-built server. When neither exists, AstroErrorData.NoManifestAvailable is thrown — the constructor ran outside an Astro server, so no routes, directives, or settings are known.","triggerScenarios":"Constructing FetchState directly in a plain Node script, a unit test, or an unbundled import of server code where the virtual manifest module was never loaded and nothing called setAmbientManifest; a custom host importing the handler modules outside the built entry.","commonSituations":"Unit-testing astro/fetch handler functions in isolation; running the server entry with a custom loader that skips Vite's virtual modules; an integration that spins up its own request handling instead of reusing the built dist/server/entry.mjs.","solutions":["Only create FetchState inside a request handled by an Astro-built server (the built entry or astro dev)","For custom hosts, register the SSR manifest first with setAmbientManifest(...) from the manifest module before any request","In tests, import the built server entry (dist/server/entry.mjs) or use Astro's test utilities instead of constructing state by hand"],"exampleFix":"// before — plain node script, no server\nimport { FetchState } from 'astro/fetch';\nconst state = new FetchState(new Request('http://localhost/page'));\n\n// after — go through the built server's handler\nimport { handler } from './dist/server/entry.mjs';\nconst response = await handler(new Request('http://localhost/page'));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const state = new FetchState(request);\n} catch (err) {\n  if (err instanceof Error && /no manifest is available/i.test(err.message)) {\n    throw new Error('FetchState must be created inside an Astro-built server (built entry or astro dev)', { cause: err });\n  }\n  throw err;\n}","preventionTips":["Only construct FetchState within a request handled by the Astro-built server","Custom hosts must register the SSR manifest (setAmbientManifest) before the first request","In tests, import the built server entry (dist/server/entry.mjs) instead of constructing state directly"],"tags":["manifest","fetch-state","bootstrap","server-entry","ambient"],"backgroundTag":"missing-build-manifest","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}