Start: a `+` in the project path leaks server code into the client build (unescaped `new RegExp(routeTreePath)`), and memory grows without limit
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 62/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, react, typescript, vite
- 領域
- build-system, tooling
調査の方向性
@tanstack/start-plugin-core/dist/esm/vite/start-router-plugin/plugin.js の config() フックから始めてください。そこでは new RegExp(resolvedGeneratedRouteTreePath) から clientTreePlugin.load.filter が設定されています。再現するには、パスに + を含むプロジェクトをビルドし、test(path) が false を返すことを確認します。フィルターがそのようなパス内の生成済みルートツリーに一致し、クライアントビルドがサーバーモジュールを外部化しなくなれば完了です。この issue では、同じパターンを確認する場所として rsbuild/watch-ignored.js も挙げられています。
索引モデルが issue の本文から書いたものです。
説明
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:
// @tanstack/start-plugin-core/dist/esm/vite/start-router-plugin/plugin.js (1.171.54 and 1.171.55)
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); // false
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-testand 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
- 主要言語
- TypeScript
- スター
- 15.3k
- フォーク
- 1.9k
- 平均マージ
- 20時間 30分
- マージ済み PR(30日)
- 55
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/router のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortError対応中かも @unjica が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
TanStack/router#8776 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Router devtools crash when search params contain a BigInt (JSON.stringify in history tracking)対応中かも @A-Raphie が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
docs: `createLink` has no API reference page; 3 how-to guides link to a missing `#createlink` anchor対応中かも @A-Raphie が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
Inline scripts are duplicated after hydration when the CSP nonce is sent in a header対応中かも @gabriel-le が 35 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
TanStack/router の issue をすべて見る
似ている issue
-
needs-area
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Azure/typespec-azure#5936 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
vercel-labs/scriptc#2910 ·
メンテナーはふだん 1 日以内に返信
-
automation missing-model model-sync provider:fireworks-ai
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
anomalyco/models.dev#12458 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信