Why server/start.ts is hand-written

Why server/start.ts is hand-written

server/start.ts is warpkit's production entry point: it starts the job workers, Sentry and the startup reconcilers, serves prerendered and static files, and hands the rest to SSR. CLAUDE.md keeps the rules; this page keeps the reasons, so nobody re-litigates them.

Startup/shutdown logic (job workers, Sentry init, startup reconciliation) lives in server/start.ts, the production entry point , not in a server/plugins/ Nitro-plugin convention. That convention existed here previously but never actually ran: Nitro's plugin auto-load only fires when Nitro's own Vite plugin is registered with a scanDirs pointing at server/, which this project's vite.config.ts never did. defineNitroPlugin was being imported and called but nothing ever executed it, in dev, in bun run build, or in the built bundle , see docs/warpkit/features/jobs.md for the full incident writeup.

Nitro itself is no longer a dependency of this project at all (confirmed: no nitropack anywhere in node_modules; the clean script's .nitro/.output cleanup targets are dead leftovers, not evidence Nitro is still involved). This project's TanStack Start version builds directly on Vite - no Nitro adapter in the chain - so the original plugin-auto-load bug above is now moot as a live risk. But server/start.ts staying a hand-written entry point isn't a Nitro leftover either: it's a still-current tradeoff. TanStack Start's own build tooling has one built-in mechanism for combined static+SSR serving with zero extra packages - previewServerPlugin in @tanstack/start-plugin-core - and it's scoped to vite preview only. It works by registering its SSR handler after Vite's own static-file middleware, so prerendered/static files fall through automatically with no hand-maintained routing table; but that plugin has no clustering, no job-worker or Sentry boot hooks, and isn't meant for real production traffic. There is also a separate, real, currently-documented production option: nitro/vite (import { nitro } from 'nitro/vite', used as nitro({ preset: 'bun' }) alongside tanstackStart() - see tanstack.com/start/latest/docs/framework/react/guide/hosting). This project doesn't use it - not because it doesn't exist (an earlier version of this note wrongly claimed that), and the question is now settled, not open: checked directly against the installed nitro package's actual generated production entry point (node_modules/nitro/dist/presets/bun/runtime/bun.mjs) - it calls Bun.serve({...}) with no reusePort option, and nothing in the package sets one for the bun preset. Nitro's clustering support is real but lives only in a separate node-cluster preset built on Node's native cluster module, wired to Nitro's Node runtime, not the Bun one - no bridge between the two. That rules out nitro({ preset: 'bun' }) as a cluster.ts replacement outright (short of giving up bun:sqlite/Bun-native APIs for preset: 'node', or dropping per-host clustering for a different scaling topology entirely - both out of scope for this template). So server/start.ts stays hand-rolled, including its own static-vs-SSR request routing (the PRERENDERED map + the static-asset branch below it). The flat static-path list itself no longer has to be kept in sync by hand, though - src/lib/prerendered-paths.ts (STATIC_HTML_PATHS, NON_HTML_PRERENDERED_PATHS) is imported by both vite.config.ts's filter/pages and server/start.ts's PRERENDERED map, after the duplicated-list version of this exact bug broke robots.txt/sitemap.xml. /blog/* stays outside that shared list since both files already derive it independently from content-collections data.