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

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: The contributor selected this issue after an agent-assisted search and requested implementation, verification and review before submission.

Guidance: Keep the change minimal, address the underlying cause, preserve existing behaviour and avoid unrelated cleanup.

Analysis

After more than 1,000 watch events, processFileChanges skips the open/close conversion. When unrelated watch paths are filtered out, the dependency's change between disk and unsaved contents is lost, so the importer can reuse a stale program.

Fix

Run the existing conversion after either watch-processing branch, before evicting open files from the cache. This preserves watch filtering and the bulk invalidation rules.

Tests cover opening and closing at 0, 999, 1,000 and 1,001 events, preserved unrelated diagnostics, disk edits and deletion, and unchanged program/configuration reuse. Both stale-diagnostic cases 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 repetitions of the new regressions with -race.

The macOS run used a resolved TMPDIR path for an existing codegen test.

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