Skip to content

fix(typescript): avoid OOM in check-types by batching tsserver open/close#10351

Merged
davidfirst merged 2 commits into
masterfrom
fix-check-types-oom
May 7, 2026
Merged

fix(typescript): avoid OOM in check-types by batching tsserver open/close#10351
davidfirst merged 2 commits into
masterfrom
fix-check-types-oom

Conversation

@davidfirst
Copy link
Copy Markdown
Member

bit check-types opened every .ts/.tsx file in the workspace upfront via Promise.all, so tsserver loaded the closest tsconfig project for each file and held them all in memory. The existing BATCH_SIZE=50 only batched the geterr call — by then everything was already loaded, so it never bounded memory and large workspaces would hang or OOM.

Now files are opened and closed in batches inside getDiagnostic (one updateOpen round-trip per batch), so tsserver only holds one batch's worth of files at a time. Added a status line so the run shows progress instead of looking hung.

No new flags or memory tuning — defaults are unchanged.

Copilot AI review requested due to automatic review settings May 7, 2026 16:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent bit check-types from hanging or OOM’ing in large workspaces by changing the tsserver interaction so TypeScript projects aren’t all loaded into memory at once.

Changes:

  • Add CLI status-line progress messages during check-types execution.
  • Add openFilesOnInit?: boolean to TsserverClient so callers can skip pre-opening all files during init.
  • Update TsserverClient.getDiagnostic() to (intended) open/check/close files in batches to bound tsserver memory usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scopes/typescript/typescript/cmds/check-types.cmd.ts Sets status lines for progress and disables pre-opening files on tsserver init so diagnostics can be batched.
scopes/typescript/ts-server/ts-server-client.ts Adds openFilesOnInit and implements batched UpdateOpen open/close behavior around geterr, plus progress status line.

Comment thread scopes/typescript/ts-server/ts-server-client.ts Outdated
Comment thread scopes/typescript/ts-server/ts-server-client.ts Outdated
Comment thread scopes/typescript/ts-server/ts-server-client.ts Outdated
Comment thread scopes/typescript/typescript/cmds/check-types.cmd.ts Outdated
@davidfirst davidfirst enabled auto-merge (squash) May 7, 2026 17:33
@davidfirst davidfirst merged commit caa07d4 into master May 7, 2026
12 checks passed
@davidfirst davidfirst deleted the fix-check-types-oom branch May 7, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants