Repository navigation
Invalidate cached TS responses after document reopen - #347028
Merged
Dirk Bäumer (dbaeumer) merged 1 commit intoNov 10, 2026
Merged
Dirk Bäumer (dbaeumer) merged 1 commit into
Dirk Bäumer (dbaeumer) merged 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the fix for stale TypeScript cache results when documents are reopened.
No open issues 🎉
What changed in this PR
Fixes #347026 by preventing the TypeScript response cache from reusing stale results when a document is closed and reopened with the same URI and version but different content.
Changes:
- Matches cached responses by weak document identity and version, preserving same-document cache hits without strongly retaining closed documents.
- Adds cache-level and document-symbol regressions covering document closure, external edits, and reopening.
| File | Description |
|---|---|
extensions/typescript-language-features/src/tsServer/cachedResponse.ts |
Replaces URI matching with weak document identity matching. |
extensions/typescript-language-features/src/test/unit/cachedResponse.test.ts |
Tests cache invalidation when a document is reopened. |
extensions/typescript-language-features/src/test/smoke/documentSymbol.test.ts |
Tests that document symbols reflect external edits after reopening. |
Review effort: Balanced
Dirk Bäumer (dbaeumer)
approved these changes
Nov 10, 2026
Dirk Bäumer (dbaeumer)
enabled auto-merge
November 10, 2026 11:07
Ladislau Szomoru (lszomoru)
approved these changes
Nov 10, 2026
Giuseppe Cianci (Giuspepe)
approved these changes
Nov 10, 2026
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 #347026
A reopened document can have the same URI and version as an earlier document while containing different text. Match cached TypeScript responses by weak document identity and version so old navigation-tree results cannot satisfy the reopened document's request. Same-document cache hits remain, without strongly retaining closed documents.
A cache regression and a real-extension
vscode.executeDocumentSymbolProviderregression fail before the fix. The selected suite passes 15 tests with one existing skip; extension compilation, web typechecking and targeted ESLint pass.An independent comparison with installed 1.145.2 uses its packaged TypeScript extension and observes actual document closure and a distinct reopened version-1 document. Stable returns
originalwhile the public editor text containsupdated; patched main returnsupdated. Neither run deletes/recreates the file.