Dev server hot reload removes one API route
I have a very odd (and very minor) issue that I repeatedly run into. My workflow (using jj-vcs) involves me doing a lot of rebases or other changes to the git log.
Very often I find that when I am running the vite dev server while performing these rebase operations, the automatic route tree generated by TanStack Start/Router (I believe -
routeTree.gen.ts) will remove exactly one route from my route tree, until I restart the dev server, at which point it regenerates it back in and the file is once again unchanged.
That route is consistently the one at const ApiElectricRouteImport = createFileRoute('/api/electric')()
I have a maybe slightly complicated route structure in there, which is the only thing I can think of that might be causing it. I'm trying to take advantage of pathless routes here:
Originally posted in the tanstack db section but advised to ask over here.5 Replies
rival-black•4w ago
can you please provide a complete example project that reproduces this?
flat-fuchsiaOP•4w ago
here you go.
I ran
pnpm create @tanstack/start@latest route-issue-repro, then added the following nested API structure:
if you unzip it, pnpm install, and start the dev server (pnpm dev) and then run:
git checkout 4f6b98c7 (the commit with description "test return ok")
you should see the lineconst ApiTestRouteImport = createFileRoute('/api/test')() removed, as well as related lines. Restarting the dev server after this restores those changes.
the full sequence looks smth like this
hopefully that reproduces it for you too! let me know if you have any questionsflat-fuchsiaOP•4w ago
it seems to be only triggered by the nested pathless routes
rival-black•3w ago
yeah looks like a bug
can you please create a github issue for this so we can properly track this?
flat-fuchsiaOP•2w ago
done, here you go! https://github.com/TanStack/router/issues/5862
GitHub
Dev server hot reload erroneously removes nested pathless API route...
Which project does this relate to? Router Describe the bug Given a route tree with nested pathless routes like this: > tree src/routes/api src/routes/api └── test └── _session ├── _admin │ ├── a...