You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
tsc -b --watch takes tens of seconds to start watching on a large project-references solution (computeDesiredWatches is O(files × dirs)) #4614
[email protected] (also reproduces on the 7.1.0-dev nightly). macOS (arm64), Node 24. tsc execs the platform tsgo binary, so tsc -b --watch and tsgo -b --watch are the
same native code.
Summary
On a large tsc -b --watch solution, Found 0 errors. Watching for file changes. prints
within a couple of seconds, but no filesystem watch is actually registered until computeDesiredWatches returns, which on a large solution takes tens of seconds. Any
edit made during that window is silently lost (fsevents does not replay pre-arm events),
so the watch appears dead. Plain tsc --watch (single project, no -b) is unaffected.
npm install
npm run setup # generates 15 projects x 1500 shared node_modules packages
npm run watch # tsc -b --watch --preserveWatchOutput
Watching for file changes. prints within ~2s, then the process pegs a CPU core before
any watch exists. On this solution that is ~85s. To confirm nothing is watched yet:
edit a file within the first minute → nothing happens; edit again after the CPU drops to
idle → picked up in ~1s. A single small project returns in milliseconds, so this only
appears at solution scale.
Cause
computeDesiredWatches (internal/execute/build/orchestrator.go) is O(total input +
buildinfo files × number of desired watch dirs). It calls watchmanager.IsDirCoveredByWatch
for every input file, every buildinfo file, and every package.json ancestor across all
projects, and that helper linearly scans the entire desired-dirs map:
On the repro: 23,745 buildinfo files × ~1,534 desired dirs. Realpath is only ~130ms of
the total, so the cost is the coverage scan, not I/O. ReconcileWatches (which actually
registers the watches) runs only after computeDesiredWatches returns, which is why the
process looks idle to the user while the watch is still dead.
Reacted by Tomasz Robaczewski, lin72h and Alejandro Hernandez
Reacted by Søren Sønderby Nielsen, Stef Schoonderwoerd and Francisco Carvalho
We upgraded from @typescript/native-preview to [email protected] (npm latest) and hit this in a pnpm monorepo. On a package with ~630 files and 6 project references, tsc -b --watch sits at ~110% CPU for about 3 minutes after printing Watching for file changes, and edits made during that window are dropped, so the watch looks dead.
Confirmed fixed on the nightlies: 7.1.0-dev.20260728.1 still reproduces, 7.1.0-dev.20260730.1 does not.
Since 7.0.2 is latest and 7.1 stable isn't until November, a 7.0.x patch would help.
Activity
mt-bt commentedon Aug 14, 2026
Is there any plan to backport this to 7.0.x?
We upgraded from
@typescript/native-previewto[email protected](npmlatest) and hit this in a pnpm monorepo. On a package with ~630 files and 6 project references,tsc -b --watchsits at ~110% CPU for about 3 minutes after printingWatching for file changes, and edits made during that window are dropped, so the watch looks dead.Confirmed fixed on the nightlies:
7.1.0-dev.20260728.1still reproduces,7.1.0-dev.20260730.1does not.Since 7.0.2 is
latestand 7.1 stable isn't until November, a 7.0.x patch would help.jakebailey commentedon Aug 14, 2026
Yes, after #4918