LSP: changes to files not open in editor are sometimes not picked up
Closed this issue · 4 comments
Essentially after switching branch, sometimes, particularly when alot of file changes are made, tsgo seems to have an old version of project files not open in the editor, cached.
Issue started occurring after snapshot LSP was merged.
Steps to reproduce
I was re-testing #1265 but I have seen this just in day-2-day too.
- switch branch - have a file open that uses something from a file edited on another branch
logs do detect file changes:
======== Cloning snapshot 92 ========
[08:23:47.134] DidChangeFiles
[08:23:47.134] Checking for changes affecting config files
[08:23:47.134] Summarizing file changes
[08:23:47.134] Checking if any changed files are config files
[08:23:47.134] DidRequestFile
[08:23:47.134] Acquiring config for project
[08:23:47.134] CompilerHost
[08:23:47.965] Program update for c:/Projects/x/y/src/frontend/tsconfig.json completed in 831.249ms
[08:23:47.965] Finished cloning snapshot 92 into snapshot 93 in 831.249ms
[08:23:48.033]
Project 'c:/Projects/x/y/src/frontend/tsconfig.json'
Files (15029)
-----------------------------------------------
[08:23:48.053] Updated watch: affecting locations for c:/Projects/x/y/src/frontend/tsconfig.json watcher 200
[08:23:48.053] C:/Projects/x/y/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053] C:/Projects/x/y/src/openapi-clientlib/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053] C:/Projects/x/y/src/toolkit/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053] C:/Projects/x/y/src/ui/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053] C:/Projects/x/y/tools/sharedtypes/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053] c:/Projects/x/y/node_modules/**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053] c:/Projects/x/t/src/frontend/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,json}
[08:23:48.053]
[08:23:48.284] Updated watch: failed lookups for c:/Projects/x/y/src/frontend/tsconfig.json watcher 201
<long list of every file/folder in the project>
[08:23:48.286] Scheduling new diagnostics refresh...
[08:23:48.297] Scheduling new snapshot update...
======== Cloning snapshot 94 ========
[08:23:48.531] DidRequestFile
[08:23:48.531] Acquiring config for project
[08:23:48.531] Finished cloning snapshot 94 into snapshot 95 in 0s
======== Cloning snapshot 95 ========
[08:23:48.531] DidRequestFile
[08:23:48.531] Acquiring config for project
[08:23:48.531] Finished cloning snapshot 95 into snapshot 96 in 0s
======== Cloning snapshot 93 ========
[08:23:47.965] DidRequestFile
[08:23:47.965] Acquiring config for project
[08:23:47.965] CompilerHost
[08:23:48.529] Program update for c:/Projects/x/y/src/portfolio/tsconfig.json completed in 563.3994ms
[08:23:48.531] Finished cloning snapshot 93 into snapshot 94 in 566.0796ms
<another updated watch and updated watch failed>
[08:23:48.786] Running scheduled diagnostics refresh
[08:23:48.788] Processed 978 file changes in 1.4577ms
[08:23:48.788] Canceling scheduled snapshot update and performing one now
======== Cloning snapshot 96 ========
[08:23:48.789] DidChangeFiles
[08:23:48.789] Checking for changes affecting config files
[08:23:48.789] Summarizing file changes
[08:23:48.790] Checking if any changed files are config files
[08:23:48.790] DidRequestFile
[08:23:48.790] Acquiring config for project
[08:23:48.791] Finished cloning snapshot 96 into snapshot 97 in 2.5711ms
[08:23:48.791] Scheduling new diagnostics refresh...
[08:23:49.291] Running scheduled diagnostics refresh
[08:23:59.519] Scheduling new snapshot update...
[08:24:00.037] Processed 69762 file changes in 15.3193ms
[08:24:00.037] Running scheduled snapshot update
======== Cloning snapshot 97 ========
[08:24:00.037] DidChangeFiles
[08:24:00.037] Checking for changes affecting config files
[08:24:00.037] Summarizing file changes
[08:24:00.049] Checking if any changed files are config files
[08:24:00.050] Checking if any of 9769 created files match root files for config c:/projects/x/y/src/frontend/tsconfig.json
[08:24:00.050] Checking if any of 9769 created files match root files for config c:/projects/x/y/src/portfolio/tsconfig.json
[08:24:00.061] Marking project c:/Projects/x/y/src/frontend/tsconfig.json as dirty
[08:24:00.069] Marking project c:/Projects/x/y/src/portfolio/tsconfig.json as dirty
[08:24:00.069] Finished cloning snapshot 97 into snapshot 98 in 32.6397ms
- an error appears in the open file that is incorrect. e.g.
- wait 9 minutes - no change in errors or tslog
[08:24:21.054] Scheduling new snapshot update...
[08:24:21.555] Processed 2 file changes in 0s
[08:24:21.555] Running scheduled snapshot update
======== Cloning snapshot 102 ========
[08:24:21.555] DidChangeFiles
[08:24:21.555] Checking for changes affecting config files
[08:24:21.555] Summarizing file changes
[08:24:21.555] Checking if any changed files are config files
[08:24:21.555] Finished cloning snapshot 102 into snapshot 103 in 0s
[08:24:21.555] Scheduling new diagnostics refresh...
[08:24:22.055] Running scheduled diagnostics refresh
-
open the file that changed with the branch switch, where it says the function doesn't exist, but it does since the branch change
-
the error caused by having an old version of the file disappears - other errors from other files updated still remain
Huh, apparently we never ported file watching for “closed script info” either in the old project service or the new snapshot code.
#1733 improves the situation, but it looks like VS Code sometimes drops events when there is a big flood of changes. We probably need to implement a full file cache clear over some threshold of accumulated watch events.
I'm sorry, I'm on holiday for the next week. I can check after that - but I will need instructions on how to get it into vscode if its still not merged by then :/