Repository navigation
Preserve dependency invalidation after large watch batches - #65718
Open
benjibun (benjibunbun) wants to merge 1 commit into
Open
benjibun (benjibunbun) wants to merge 1 commit into
benjibun (benjibunbun) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
processFileChangesskips 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 --allnpx hereby tidynpx hereby check:format-race.An existing codegen test needed a resolved
TMPDIRpath on macOS.