{"record":{"id":"d8707df84338b834","repo":"anomalyco/sst","slug":"tanstack-start-server-bundle-not-found-at-se","errorCode":null,"errorMessage":"TanStack Start server bundle not found at:\n  \"${serverPath}\".","messagePattern":"TanStack Start server bundle not found at:\n  \"(.+?)\"\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/cloudflare/tan-stack-start.ts","lineNumber":322,"sourceCode":"              directory?: string;\n            };\n          };\n          if (!wrangler.main) {\n            throw new VisibleError(\n              `TanStack Start build output at \"${path.resolve(wranglerPath)}\" is missing the Worker entry in \\`main\\`.`,\n            );\n          }\n\n          const serverPath = path.resolve(outputPath, \"dist\", \"server\", wrangler.main);\n          const assetsPath = path.resolve(\n            outputPath,\n            \"dist\",\n            \"server\",\n            wrangler.assets?.directory ?? \"../client\",\n          );\n\n          if (!(await existsAsync(serverPath))) {\n            throw new VisibleError(\n              `TanStack Start server bundle not found at:\\n  \"${serverPath}\".`,\n            );\n          }\n          if (!(await existsAsync(assetsPath))) {\n            throw new VisibleError(\n              `TanStack Start assets directory not found at:\\n  \"${assetsPath}\".`,\n            );\n          }\n\n          return {\n            server: toPlanPath(serverPath),\n            assets: toPlanPath(assetsPath),\n          };\n        }\n\n        for (const serverFile of [\"index.js\", \"index.mjs\"]) {\n          const serverPath = path.join(\n            outputPath,","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/cloudflare/tan-stack-start.ts#L304-L340","documentation":"Having parsed `dist/server/wrangler.json`, SST resolves the server entry (`main`, e.g. `index.js`) relative to `dist/server`. If that file does not exist on disk, the build output is incomplete or inconsistent with wrangler.json, and SST throws.","triggerScenarios":"`dist/server/wrangler.json` lists a `main` whose file isn't present: stale wrangler.json from an old build, interrupted build, or the adapter writing a main path that the build didn't emit.","commonSituations":"Deploying after a partially failed build; mixing old dist output with new config; committing dist to git so stale wrangler.json points at removed files.","solutions":["Delete `dist/` and run a full clean build with the Cloudflare adapter","Confirm the file referenced by wrangler `main` exists under `dist/server` before deploying","Stop committing build output; build fresh in CI"],"exampleFix":"// before: dist/server/wrangler.json says main: index.js but only index-abc123.js exists\nrm -rf dist\n// after: rebuild so main and emitted file match, then sst deploy","handlingStrategy":"validation","validationCode":"import { readFileSync, existsSync } from 'fs';\nconst w = JSON.parse(readFileSync('apps/web/dist/server/wrangler.json', 'utf8'));\nif (!existsSync(`apps/web/dist/server/${w.main}`))\n  throw new Error(`Server bundle missing: dist/server/${w.main}; clean dist and rebuild`);","typeGuard":null,"tryCatchPattern":"try {\n  await deploy();\n} catch (e) {\n  if (/server bundle not found/.test(e.message)) console.error('Stale or partial dist output; rebuild from clean');\n}","preventionTips":["Clean dist after adapter/config changes","Never mix old build output with new config","Verify wrangler main file exists before deploy","Build fresh in CI instead of caching dist"],"tags":["tanstack-start","cloudflare","build-output","missing-file"],"backgroundTag":"build-output-not-found","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}