An include-style root tsconfig is not detected, so the TypeScript tier still indexes the whole root

オープン
#1,960 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, typescript

調査の方向性

Start with scripts/scip_harness/scip_ts_projects.py discovery and run_typescript_delta.sh selection, then trace how discovered projects reach server/code/workers/scip_ts_delta.py and dependency preparation in server/code/app/index/typescript_dependencies.py. The issue describes several connected gaps and leaves the intended include-style root behavior open. Done means the chosen behavior is documented or implemented, with coverage for the include-style root and BOM-prefixed tsconfig cases.

索引モデルが issue の本文から書いたものです。

説明

Company

Independent

Component

Code index

Describe what's wrong

A large pnpm monorepo whose root tsconfig.json uses include and has no references is still indexed as one program, and runs out of memory as #1678 reported. #1782 detects an umbrella root with references and no files of its own (is_umbrella_tsconfig, scripts/scip_harness/scip_ts_projects.py:95-105), the shape #1678 described. That description was our error: the root has "include": ["src/**/*", "ui/**/*", "extensions/**/*", "packages/**/*"], over 200 paths entries and no references. So discover prints nothing and run_typescript_delta.sh (:49-55) indexes the root with --pnpm-workspaces, the path that ran out of memory:

run heap (NODE_HEAP_MB) result
--full, no project list, main 8,192 (default) V8 heap out of memory after 233 s, peak RSS 8.14 GiB, exit 134
--full, no project list, #1782's head before the merge 24,576 no project finished after 2,712 s, RSS 23.9 GB and rising (stopped)

With scip_ts_projects listed by hand (15 directory patterns, 222 to 226 projects as the repository changes), #1782's per-member runs and delta selection do work on this repository: a delta in one package runs one project in under a minute at 0.95 GB. Delta narrowing therefore reaches this shape only through a hand-written list.

Detection has three smaller gaps on the same path:

  1. A root tsconfig.json that starts with a UTF-8 BOM is read with encoding="utf-8" (scip_ts_projects.py:84), json.loads rejects the BOM, the stripped retry fails too, and discover returns nothing with exit 0. TypeScript accepts the BOM, so a BOM-prefixed umbrella takes the whole-root path.
  2. Every parse error, missing file and reference outside the checkout in discover returns an empty list or skips the entry, and a non-zero exit from discover reads as "not an umbrella" (run_typescript_delta.sh:49). The pass then indexes the root with no log line naming the root that was rejected and why.
  3. Discovered members exist only inside the harness. The worker's dependency preparation still receives cfg.scip_ts_projects (server/code/workers/scip_ts_delta.py:135, prepare_dependencies in server/code/app/index/typescript_dependencies.py), so an umbrella that is not a workspace and keeps a lockfile per member is installed at the root only, and _delta_shape (scip_ts_delta.py:179), the key for holding a refused pass, does not include the discovered set.
Does it reproduce on the latest release or main?

Yes

How to reproduce

Detection, from a checkout of main:

mkdir -p tree/packages/app tree/packages/lib
echo '{"include": ["packages/**/*"]}' > tree/tsconfig.json
echo '{"include": ["src"]}' > tree/packages/app/tsconfig.json
echo '{"include": ["src"]}' > tree/packages/lib/tsconfig.json
python3 scripts/scip_harness/scip_ts_projects.py discover tree        # prints nothing

mkdir -p bom/packages/a
printf '\xef\xbb\xbf{"files": [], "references": [{"path": "packages/a"}]}' > bom/tsconfig.json
echo '{"include": ["src"]}' > bom/packages/a/tsconfig.json
python3 scripts/scip_harness/scip_ts_projects.py discover bom; echo "rc=$?"   # prints nothing, rc=0

Without the BOM, the second tree prints packages/a.

The out-of-memory run: a full pass with scip_ts_projects unset over a pnpm workspace whose root tsconfig.json uses include across a few hundred projects, here the repository from #1678:

DELTA_OUT=full.json scripts/scip_harness/run_typescript_delta.sh /path/to/checkout --full HEAD
Expected behavior

Either of these would close the gap:

  1. The docs say that an include-style root still needs scip_ts_projects, and discover logs why it rejected a root.
  2. discover also treats a root whose include reaches directories with their own tsconfig.json as an umbrella over them. This has open questions: the root's own files outside every member directory (this repository has extensions with a package.json and no tsconfig.json), and members nested inside members (src and nine projects below it).

In both cases, load_tsconfig reads with utf-8-sig, as TypeScript accepts a BOM.

Environment
Loom main at 3058a5816 (contains #1782); the 24 GiB row ran #1782's head e8fbb33 before the merge, whose discovery code is the same.
@sourcegraph/scip-typescript 0.4.0, node 22.23.4, pnpm 12.15.0, Python 3.12.
run_typescript_delta.sh in DELTA_OUT mode, the worker's mode; no ClickHouse involved.
The repository: a pnpm workspace, root tsconfig.json with include and no references; the 30 s delta used a project list of 222 entries.
Related issues and pull requests

Related: https://github.com/ClickHouse/loom/issues/1678
Related: https://github.com/ClickHouse/loom/pull/1782

How this was found

An AI tool found it, and I have not reproduced it myself

Additional context

Tests that would cover this, each failing or undefined on main:

  1. An include-style root with workspaces (this shape): assert what the tier does, today the whole-root pass.
  2. A BOM-prefixed umbrella root: \xef\xbb\xbf{"files": [], "references": [...]}; assert the members are discovered.
Redaction
  • I removed tokens, keys, passwords and personal or customer data from everything above.
主要言語
Python
スター
221
フォーク
35
平均マージ
14時間 21分
マージ済み PR(30日)
873

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ClickHouse/loom のほかの issue

ClickHouse/loom の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。