Which project does this relate to?#
Start
Describe the bug#
start-plugin-core builds a RegExp from the absolute path of the generated route tree without escaping it:
config() {
resolvedGeneratedRouteTreePath = normalizePath(getGeneratedRouteTreePath());
clientTreePlugin.load.filter = { id: { include: new RegExp(resolvedGeneratedRouteTreePath) } };
},
When the project path contains a regex metacharacter such as +, the pattern no longer matches its own file:
const p = "/x/refactor+server-function-auth/src/routeTree.gen.ts";
new RegExp(p).test(p);
So tanstack-start:route-tree-client-plugin never loads the route tree for the client environment, and pruneServerOnlySubtrees is skipped. The client build then pulls in server-only code. In my app that's firebase-admin, @grpc/grpc-js, google-auth-library and Node built-ins: 265 Module "…" has been externalized for browser compatibility warnings. The build process then keeps allocating memory until the OS kills it. I saw 98 GB, which filled the swap on an 18 GB Mac.
This is easy to hit now: Claude Code names git worktrees by replacing / in the branch name with +, e.g. .claude/worktrees/refactor+server-function-auth.
Steps to reproduce#
- Create any TanStack Start app with a server function that imports a Node-only package.
- Put it in a folder whose name contains
+, e.g. mv app app+test.
- Run
vite build.
- Server modules show up in the client build and memory grows without limit. Rename the folder to
app-test and the build is normal.
Measured on the same checkout and the same node_modules:
| Folder name | Peak memory | "externalized for browser" warnings | Result |
|---|
refactor+server-function-auth | >8.5 GB in 16s, still climbing | 265 | killed |
refactor-server-function-auth | 1.4 GB | 0 | ✓ built in 12s |
Suggested fix#
Escape the path before building the RegExp, e.g. new RegExp(escapeRegExp(resolvedGeneratedRouteTreePath)), or match on an exact id instead of a regex. A quick search found a few other new RegExp(...) calls built from values that could contain metacharacters, e.g. rsbuild/watch-ignored.js. They might be worth a look too.
Versions#
- @tanstack/react-start 1.169.3, @tanstack/start-plugin-core 1.171.54 (the same code is still in 1.171.55)
- vite 8.3.4 (rolldown), nitro 3.0.260903-beta
- Node 24, pnpm 11.1.1, macOS 26 (Darwin 27.2), Apple Silicon
please provide a complete reproducer project