VS Code file watcher and TypeScript language service: cache invalidation boundary during bulk file-system mutations
0 reputation · 03 Apr 2020, 06:19 UTC
0 reputation · 03 Apr 2020, 06:19 UTC
VS Code's file watcher (Chokidar) and the TypeScript language service (tsserver) form an integration boundary where external bulk mutations — git checkout, reset, pull, or package-manager installs (npm ci, yarn install, pnpm install) — can leave tsserver's in-memory symbol indexes and module-resolution caches stale. The watcher may coalesce or drop events when large directory trees are replaced atomically, and VS Code does not automatically restart the TS server in response.
No public event signals "external bulk change detected" for extensions to trigger automated recovery. The heuristic for deciding when a restart is warranted remains undocumented and varies by OS watcher backend (inotify, kqueue, FSEvents, polling). Remote development (WSL, SSH, Dev Containers) adds another watcher layer that can further delay or drop events. Behavior has been observed on VS Code 1.85–1.93; newer releases may introduce undocumented heuristic restarts.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.