{"record":{"id":"0f63f6e4162bf35b","repo":"sveltejs/kit","slug":"could-not-find-server-asset-file","errorCode":null,"errorMessage":"Could not find server asset ${file}","messagePattern":"Could not find server asset (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-bun/index.js","lineNumber":337,"sourceCode":"\t\t\t\tthrow new Error(`Could not find prerendered page ${file} for route ${path}`);\n\t\t\treturn entry(page, 'prerendered_page', path);\n\t\t}),\n\t\t...pr_pages\n\t\t\t.filter(({ rel }) => !page_rels.has(rel))\n\t\t\t.map((file) => entry(file, 'prerendered_asset')),\n\t\t...[...pr_deps, ...pr_data].map((file) => entry(file, 'prerendered_asset'))\n\t]);\n\n\tconst index_by_rel = new Map(\n\t\tassets.map(({ rel }, i) => /** @type {[string, number]} */ ([rel, i])).reverse()\n\t);\n\n\treturn {\n\t\timports,\n\t\tentries,\n\t\tserver_assets: server_assets.map((file) => {\n\t\t\tconst idx = index_by_rel.get(file);\n\t\t\tif (idx === undefined) throw new Error(`Could not find server asset ${file}`);\n\t\t\treturn `[${JSON.stringify(file)}, server_asset(${JSON.stringify(file)}, asset_${idx})]`;\n\t\t})\n\t};\n}\n\n/**\n * @param {object} options\n * @param {Builder} options.builder\n * @param {string[]} options.server_assets\n * @param {string} options.out\n * @param {boolean} options.precompress\n * @returns {Promise<{imports: string[], entries: string[], server_assets: string[]}>}\n */\nasync function get_no_embed_entries({ builder, server_assets, out, precompress }) {\n\tconst client_files = builder.writeClient(`${out}/client`).filter((file) => !is_dotfile(file));\n\tconst prerendered_files = builder.writePrerendered(`${out}/prerendered`);\n\tvalidate_file_paths([...client_files, ...prerendered_files]);\n","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-bun/index.js#L319-L355","documentation":"adapter-bun embeds server assets (files listed in the server build manifest that must be served at runtime) by matching each asset path against an index of emitted build artifacts. When a server asset recorded in the manifest has no corresponding emitted artifact, this error is thrown.","triggerScenarios":"get_embed_entries maps the server_assets list through index_by_rel (built from emitted artifacts); the index lacks an entry for `file`, so the server_asset embedding line cannot be generated.","commonSituations":"Server-side referenced assets excluded from the Bun build outputs; misconfigured adapter assets option; stale build caches; assets moved/renamed between manifest generation and embedding.","solutions":["Clean and rebuild: rm -rf build .svelte-kit then `bun run --bun build`.","Ensure referenced server-side assets are inside the project and included in the build outputs (check the adapter's assets/out config).","Verify the files actually exist at the referenced paths and haven't been renamed or gitignored.","Update @sveltejs/adapter-bun and Bun, since manifest/artifact mismatches can be fixed upstream."],"exampleFix":"// before\n// adapter config excludes the asset dir so the artifact is never emitted\n// after\nconst config = {\n  kit: {\n    adapter: adapter({ assets: 'src/lib/server/assets' })\n  }\n};","handlingStrategy":"validation","validationCode":"// ensure every server asset has an emitted artifact before adapting\nconst indexByRel = new Map(artifacts.map((a, i) => [a.rel ?? a.path, i]));\nfor (const file of serverAssets) {\n  if (!indexByRel.has(file)) {\n    throw new Error(`Server asset ${file} was not emitted by the Bun build — check adapter assets config`);\n  }\n}","typeGuard":"const assetIsEmitted = (indexByRel, file) => indexByRel.has(file);","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (/Could not find server asset/.test(e.message)) {\n    const file = /server asset (\\S+)/.exec(e.message)?.[1];\n    console.error(`${file} missing from build outputs — include it in the build or fix the assets config, then rebuild.`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Keep server-referenced assets inside directories included in the build","Avoid gitignoring or moving assets mid-build","Clean rebuild when the manifest and artifacts disagree","Pin and update adapter-bun to get manifest-mismatch fixes"],"tags":["server-assets","adapter-bun","build-artifacts"],"backgroundTag":"server-asset-not-found","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}