Skip to content

fix(vscode): cache the reactivity analysis language service per project - #6327

Merged
johnsoncodehk merged 2 commits into
vuejs:masterfrom
ondrhn:fix/issue-6325-vscode-cache-the-reactivity
Dec 3, 2026
Merged

johnsoncodehk merged 2 commits into
vuejs:masterfrom
ondrhn:fix/issue-6325-vscode-cache-the-reactivity

Conversation

@ondrhn

@ondrhn ondrhn commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Reactivity Visualization attaches analyzed files to the wrong tsconfig project. Open a .vue file and a .js file that belong to separate projects and analyze the .vue file first, and tsserver starts reporting the .js file as part of the .vue file's project. If that project's program does not contain the file, as with a JS entry file under a tsconfig.app.json without allowJs, every semantic request for it then fails with "Could not find source file", so hover and completion answer nothing.

reactivityAnalysisPlugin.ts kept the single-file language service in a module-level variable (together with currentFileName/currentSnapshot/currentVersion), so the host created on the first _vue:getReactivityAnalysis call stayed decorated with that call's language. Later calls read the right language off the project but still ran the old service, so scripts were resolved through the first project's language and from there through that project's ts.server.Project host, which attaches the file to the project and makes it the file's default project. getReactivityAnalysis now keeps one service per language in a WeakMap, each with its own file/snapshot/version state, so the service caching from #5652 is preserved and the first project's host is never asked for another project's file. The cost is one small single-file service per project, released with the language once the project is gone.

Caching the service was introduced in 3bfd059 (#5652) and moved into this plugin in 9066601 (#5672).

fix #6325

ondrhn and others added 2 commits October 30, 2026 15:55
The single-file language service was module-global, so it stayed bound to the
language of the project that first requested an analysis. Every later file was
then resolved through that project's host, which attached it to the wrong
project.
@johnsoncodehk
johnsoncodehk merged commit d1fbad8 into vuejs:master Dec 3, 2026
3 checks passed
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.

Reactivity analysis attaches a .js file to a tsconfig project that doesn't include it, so tsserver answers nothing for that file

2 participants