Skip to content

Preserve dependency invalidation after large watch batches - #65718

Open
benjibun (benjibunbun) wants to merge 1 commit into
microsoft:mainfrom
benjibunbun:fix/65638-overlay-invalidation
Open

benjibun (benjibunbun) wants to merge 1 commit into
microsoft:mainfrom
benjibunbun:fix/65638-overlay-invalidation

Conversation

@benjibunbun

@benjibunbun benjibun (benjibunbun) commented Nov 28, 2026 •

Copy link
Copy Markdown

Fixes #65638

This PR was co-authored with Codex using GPT-6 (reasoning setting unavailable). Codex implemented and tested the fix under my guidance.

Motivation & Guidance

Motivation: I chose this issue because stale diagnostics make it harder to trust the editor’s feedback. The failure is also reproducible, so there’s a clear way to verify the fix and check that existing behaviour still works.

Guidance: Keep the change small, address the underlying cause and test the existing behaviour as well as the fix. Avoid unrelated cleanup.

Analysis

For batches of more than 1,000 watch events, processFileChanges skips the open/close conversion. When unrelated watch paths are filtered out, the dependency's switch between disk and unsaved contents is lost, leaving importers with stale diagnostics.

Fix

Run the existing conversion after either watch-processing branch, before evicting open files from the cache. Watch filtering and bulk invalidation stay intact.

Tests cover opening and closing at 0, 999, 1,000 and 1,001 events, unrelated diagnostics, disk edits and deletion, and unchanged program/configuration reuse. Both stale-diagnostic regressions fail on the original code and pass with the fix.

Validation passed on macOS arm64:

  • npx hereby validate --all
  • npx hereby tidy
  • npx hereby check:format
  • Ten runs of the new regressions with -race.

An existing codegen test needed a resolved TMPDIR path on macOS.

Copilot AI balanced review requested due to automatic review settings November 28, 2026 15:23
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 28, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the fix for dependency invalidation after large watch-event batches.

No open issues 🎉

What changed in this PR

Fixes #65638 by preserving dependency invalidation when opening or closing unsaved files after large watch-event batches, preventing stale importer diagnostics in the language server.

Changes:

  • Apply open/close conversion after either watch-processing branch while preserving existing filtering and bulk invalidation.
  • Add project tests for unsaved content, disk edits, deletion, and program/configuration reuse.
  • Add language-server diagnostic regressions covering 0, 999, 1,000, and 1,001 watch events.
File Description
tsc/​internal/​project/​snapshot.go Move open/close conversion outside the watch-processing branches.
tsc/​internal/​project/​bulkcache_test.go Test dependency content updates and cache reuse after large watch batches.
tsc/​internal/​lsp/​server_watchdiagnostics_test.go Verify importer diagnostics update while unrelated diagnostics remain intact.

Review effort: Balanced

@benjibunbun

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Opening or closing an unsaved dependency leaves stale diagnostics after a large file-watch batch

2 participants