{"record":{"id":"e0969646747b45a9","repo":"anomalyco/sst","slug":"tanstack-start-build-output-at-path-resolve-wra","errorCode":null,"errorMessage":"TanStack Start build output at \"${path.resolve(wranglerPath)}\" is missing the Worker entry in `main`.","messagePattern":"TanStack Start build output at \"(.+?)\" is missing the Worker entry in `main`\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/cloudflare/tan-stack-start.ts","lineNumber":308,"sourceCode":"        ].join(\"\\n\"),\n      );\n\n      async function resolveDistPlan() {\n        const wranglerPath = path.join(\n          outputPath,\n          \"dist\",\n          \"server\",\n          \"wrangler.json\",\n        );\n        if (await existsAsync(wranglerPath)) {\n          const wrangler = JSON.parse(await fs.readFile(wranglerPath, \"utf-8\")) as {\n            main?: string;\n            assets?: {\n              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))) {","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/cloudflare/tan-stack-start.ts#L290-L326","documentation":"When SST finds `dist/server/wrangler.json` in a TanStack Start build, it reads the Worker entrypoint from its `main` field. If `main` is missing or empty, SST cannot locate the worker script and throws this VisibleError.","triggerScenarios":"A TanStack Start build emits `dist/server/wrangler.json` without a `main` property: hand-edited or stale wrangler.json, adapter misconfiguration, or an older/newer adapter writing an incompatible config shape.","commonSituations":"Manually committing a wrangler.json into dist/server that overrides the generated one; version mismatch between the TanStack Cloudflare adapter and SST's expectations; interrupted builds leaving a partial wrangler.json.","solutions":["Clean the `dist/` directory and rebuild with the official Cloudflare adapter so `main` is generated","Do not commit or hand-edit `dist/server/wrangler.json`; configure the adapter instead of editing build output","Update `@tanstack/cloudflare-vite-plugin` to a current version that writes the `main` field"],"exampleFix":"// before (dist/server/wrangler.json, hand-edited)\n{ \"name\": \"app\", \"assets\": { \"directory\": \"../client\" } }\n// after: rm -rf dist && rebuild via adapter\n{ \"name\": \"app\", \"main\": \"index.js\", \"assets\": { \"directory\": \"../client\" } }","handlingStrategy":"validation","validationCode":"import { readFileSync, existsSync } from 'fs';\nconst w = JSON.parse(readFileSync('apps/web/dist/server/wrangler.json', 'utf8'));\nif (!w.main) throw new Error('dist/server/wrangler.json missing `main`; rebuild with the Cloudflare adapter');\nif (!existsSync(`apps/web/dist/server/${w.main}`)) throw new Error(`main file missing: ${w.main}`);","typeGuard":"function wranglerHasMain(w: unknown): w is { main: string } {\n  return typeof w === 'object' && w !== null && 'main' in w && typeof (w as { main: unknown }).main === 'string' && (w as { main: string }).main.length > 0;\n}","tryCatchPattern":"try {\n  await deploy();\n} catch (e) {\n  if (/missing the Worker entry in `main`/.test(e.message)) console.error('Do not hand-edit dist/server/wrangler.json; rebuild with the adapter');\n}","preventionTips":["Never commit or hand-edit dist/server/wrangler.json","Clean dist before rebuilding","Keep the TanStack Cloudflare adapter up to date","Validate generated wrangler.json in CI"],"tags":["tanstack-start","cloudflare","wrangler-config","build-output"],"backgroundTag":"invalid-wrangler-config","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}