T
TanStack4w ago
flat-fuchsia

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:
> tree src/routes/api/electric
src/routes/api/electric
└── _session
├── activities.ts
├── admin
│ └── _admin
│ ├── messages.ts
│ ├── route.ts
│ ├── trips.ts
│ └── users.ts
├── days.ts
├── message-attachments.ts
├── message-deltas.ts
├── messages.ts
├── route.ts
├── segments.ts
└── trips.ts

4 directories, 12 files
> tree src/routes/api/electric
src/routes/api/electric
└── _session
├── activities.ts
├── admin
│ └── _admin
│ ├── messages.ts
│ ├── route.ts
│ ├── trips.ts
│ └── users.ts
├── days.ts
├── message-attachments.ts
├── message-deltas.ts
├── messages.ts
├── route.ts
├── segments.ts
└── trips.ts

4 directories, 12 files
Originally posted in the tanstack db section but advised to ask over here.
5 Replies
rival-black
rival-black4w ago
can you please provide a complete example project that reproduces this?
flat-fuchsia
flat-fuchsiaOP4w ago
here you go. I ran pnpm create @tanstack/start@latest route-issue-repro, then added the following nested API structure:
> tree src/routes/api
src/routes/api
└── test
└── _session
├── _admin
│ ├── admin_test.ts
│ └── route.ts
├── route.ts
└── test.ts

4 directories, 4 files
> tree src/routes/api
src/routes/api
└── test
└── _session
├── _admin
│ ├── admin_test.ts
│ └── route.ts
├── route.ts
└── test.ts

4 directories, 4 files
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
<-- in another terminal: start dev server, leave running -->
route-issue-repro on git HEAD (c24b5f4) via nodejs v24.3.0
> git status
Not currently on any branch.
nothing to commit, working tree clean


route-issue-repro on git HEAD (c24b5f4) via nodejs v24.3.0 took 3s
> git checkout 4f6b98c75794041c5010c90dbe20ea25da0ae21e
Previous HEAD position was c24b5f4 admin return ok
HEAD is now at 4f6b98c test return ok

route-issue-repro on git HEAD (4f6b98c) via nodejs v24.3.0
> git status
HEAD detached at 4f6b98c
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/routeTree.gen.ts

no changes added to commit (use "git add" and/or "git commit -a")

<-- in another terminal: restart dev server -->
route-issue-repro on git HEAD (4f6b98c) [!] via nodejs v24.3.0
> git status
HEAD detached at 4f6b98c
nothing to commit, working tree clean
<-- in another terminal: start dev server, leave running -->
route-issue-repro on git HEAD (c24b5f4) via nodejs v24.3.0
> git status
Not currently on any branch.
nothing to commit, working tree clean


route-issue-repro on git HEAD (c24b5f4) via nodejs v24.3.0 took 3s
> git checkout 4f6b98c75794041c5010c90dbe20ea25da0ae21e
Previous HEAD position was c24b5f4 admin return ok
HEAD is now at 4f6b98c test return ok

route-issue-repro on git HEAD (4f6b98c) via nodejs v24.3.0
> git status
HEAD detached at 4f6b98c
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/routeTree.gen.ts

no changes added to commit (use "git add" and/or "git commit -a")

<-- in another terminal: restart dev server -->
route-issue-repro on git HEAD (4f6b98c) [!] via nodejs v24.3.0
> git status
HEAD detached at 4f6b98c
nothing to commit, working tree clean
hopefully that reproduces it for you too! let me know if you have any questions
flat-fuchsia
flat-fuchsiaOP4w ago
it seems to be only triggered by the nested pathless routes
rival-black
rival-black3w ago
yeah looks like a bug can you please create a github issue for this so we can properly track this?
flat-fuchsia
flat-fuchsiaOP2w ago
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: &gt; tree src/routes/api src/routes/api └── test └── _session ├── _admin │ ├── a...

Did you find this page helpful?