CodeVetter · Repo Unpack · Behavior traces
TanStack/router
The investigation followed browser startup, client navigation, server rendering, RPC, and generated-file output through their concrete functions. Each trace retains meaningful branches such as canonical redirects, document navigation, method mismatch, or unchanged generated output. Authentication persistence was also traced through a browser-test fixture and the session wrapper. These are source-derived execution paths, not observed runtime runs.
- Browser startup: main.tsx imports routeTree → createRouter → Router constructor → RouterCore.update → ReactDOM.createRoot → RouterProvider → Matches → client Transitioner; rendering occurs only when #app exists and has empty innerHTML.
- Initial client load: Transitioner subscribes history to router.load → updateLatestLocation → buildLocation with search validation → replace/ignoreBlocker if the URL is noncanonical; otherwise it loads synchronously unless already resolved or a transaction exists.
- Primary link action: handleClick intercepts only an enabled, unmodified, unprevented left click targeting self → router.navigate → buildAndCommitLocation → commitLocation → history push/replace → subscribed router.load → loadClientRoute; absolute href or reloadDocument takes documentNavigation.
- Client route work: loadClientRoute matches routes and acquires resources → creates a LoadTransaction → runClientTransaction; contextualize establishes inherited context and beforeLoad, while loadResource executes normalized loader work.
- HTML request: createStartHandler normalizes the URL → global middleware → handleServerRoutes → executeRouter → attachRouterServerSsrUtils → router.load → serverSsr.dehydrate → renderer callback; malformed protocol-relative paths redirect with 308 and incompatible Accept headers return 406.
- React streaming: defaultStreamHandler → renderRouterToStream → React readable-stream renderer when available, otherwise pipeable renderer → transformReadableStreamWithRouter → createSsrStreamResponse; bot detection waits for full readiness rather than ordinary shell readiness.
- Server RPC: serverFnFetcher serializes and fetches → createStartHandler extracts serverFnId → handleServerAction resolves getServerFnById with client origin → rejects method mismatch before decoding → invokes action → returns a raw Response or serialized result.
- Output and persistence paths: Vite configResolved → initConfigAndGenerator → generate → Generator.run → generatorInternal → physical/virtual discovery → safeFileWrite; separately, the auth fixture's loginFn validates fixed test credentials → useSession → session.update → redirect, and logoutFn clears the session before redirecting.