You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeScript support in VSCode become unresponsive #92583
bugIssue identified by VS Code Team member as probable bugsemantic-tokensSemantic tokens issuestypescriptTypescript support issuesverifiedVerification succeeded
I'm seeing similar behavior, though restarting the TS server seemed to fix it for me temporarily. Also seeing #92652 , and restarting the TS server fixed that for me as well. However, on restarting VS Code, the problem comes back. It's inconsistent though.
I can confirm this behavior while working on mostly JavaScript. At first I thought it was my poorly scoped monolithic JS file, (and I've been slowly losing my mind since Google and GitHub seemed to be unaware of such an issue a week ago).
Brief spec:
VSCode 1.43 (stable) with TS 3.8.3 (stock), on Windows 10 x64 | 4c/8t Intel CPU, 32GiB RAM
VSCode linting / IntelliSense for JavaScript breaks seemingly for every new token or expression typed until the TS language server recovers from a seizure. Simply undoing or redoing a few times will litter the extension host output with this while TS/JS server tries to unbork itself.
Extension host terminal output:
[2020-03-17 10:11:59.613] [exthost] [error] [vscode.typescript-language-features] provider FAILED
[2020-03-17 10:11:59.613] [exthost] [error] Error: busy
at o._provideSemanticTokens (c:\Program Files\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:180337)
[2020-03-17 10:12:00.142] [exthost] [error] [vscode.typescript-language-features] provider FAILED
[2020-03-17 10:12:00.142] [exthost] [error] Error: busy
at o._provideSemanticTokens (c:\Program Files\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:180337)
[2020-03-17 10:12:00.729] [exthost] [error] [vscode.typescript-language-features] provider FAILED
[2020-03-17 10:12:00.730] [exthost] [error] Error: busy
at o._provideSemanticTokens (c:\Program Files\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:180337)
Typing out the following in any JavaScript file (on the latest stable version of VSCode) would result in 3 or 4 reinitializations for the language server:
Enabling logging or tracing doesn't point to an obvious suspect, though I don't have much experience reading those. No relevant results come up when searching through for the obvious "error", "fail", and "busy" keywords. I couldn't find "_provideSemanticTokens" either regardless of the level of verbosity. I'd include some samples, however, most of the code I'm working with is sensitive.
I'm not running with major changes. Using TypeScript 3.8.3 that VSCode comes with. Although I only see 40-60% CPU utilization for several seconds, this is making it a pain to get things done. Depending on the size of the JavaScript file open, IntelliSense seems to take longer to show up and syntax highlighting sometimes decides it should re-render. Anything except reading or scrolling through JavaScript now thrashes my CPU cores. Increasing the memory allowance to the TS server from the default of 3072 MiB to 4096 MiB did not help, and I couldn't find any settings relating to time thresholds.
Disabling all extensions (except built-ins) does not change this behavior. The size of the file doesn't seem to matter. Manually restarting the TS server does not actually help in my case. All it seems to do is quiet down the UI notification that the server features are rebooting. The laggy UX / linting / IntelliSense symptoms are still present and the ext host logs still come up with busy / fail errors.
Apologies for creating a wall of text, but I'm hoping this will help someone quickly submit a fix. Here is where the ext host error points to (formatted for readability).
Even when still minified, the column 180337 isn't too useful, as it points to somewhere in the middle of new r.SemanticTokensBuilder but since the only error is "busy," I'd say it's probably trying to point at this, which does raise an eyebrow:
If e is passed in and never mutated, and i is set to e.version and then later checked for that exact match, how can it not be equal to it? Since this check exists, I guess it has something to do with state and is expected behavior here. Hope this helps. If it's already fixed in Insiders, I'd greatly appreciate a hotfix for those of us still on stable.
Upon installing version 1.43.1, I still noticed a TypeScript failure/busy error when typing or modifying tokens. I disabled semantic highlighting globally, and the failures stopped. The insane amount of CPU thrashing also stopped.
This seems like a useful feature to have, but it's broken due to a busy timeout when some conditions are met. For people working on powerful workstations, they may not even notice it if the TypeScript language server reboots fast enough. With my settings and my JavaScript projects, it makes developing too difficult. The language features shouldn't crash every 4 seconds anyway. If anyone knows of a setting that might resolve the busy issues with semantic highlighting, please point me in the right direction.
I don't see any crashes, but I can confirm that while typing are a lot of semantic token requests fired and most of them discarded ('busy') for medium and large files.
I can imagine that adds considerable load on the TS language server and explain what Ben Arnett (@midnight-dev) is seeing.
Alexandru Dima (@alexdima), Can we throttle the requests until typing has ended?
Also, the error message printed to the ext host log is misleading
I'd like to second that request. Also, does the semantic tokens provider scan through the entire document every time it updates the semantic tokens? If so, it would greatly improve performance if it only parsed the line(s) with an active cursor.
What's special here is that editor doesn't throttle, always sends right after a change, but never sends more than one request. It waits for the last request to return until it fires the next.
Knowing that, he provider takes a chance, ask the LS right away. If it turns out to be the only change, the result can be given back to the editor without any delay. If at the time of the response we see that the document has changed, we wait until the activity has stopped before telling the server that we failed.
The server will then make a request right away.
At least that's the idea, I hope I haven't overlooked anything. I also normally do it the other way around.
Initially, the semantic tokens request would be created 500ms after typing stopped. But in #86165 the complaint is that strategy makes semantic tokens update very slowly, making semantic tokens appear laggy.
So with the changes for #86165, the request is created 300ms after the first typing, then the request is waited for, and then a new request is made if typing occurred again in the meantime, thus the rate is at most 1 every 300ms. I believe this is a sensible upper bound.
The error is logged from here, that generic piece of code does not know about the special semantic of busy errors. Rather than teaching that piece of code about busy errors, I have created #93686 to track that we introduce a special error type in vscode.d.ts and that can be instance checked and ignored for logging.
Martin Aeschlimann (@aeschli) Is there a relatively painless way to get VSCode to use this new commit since it's ultimately just a piece of the TS language server? If not, I may have to wait for Insiders to catch up. It's currently on commit 6cf3dd9 from earlier in the week.
I'm still a bit worried that there will be CPU spikes during normal, even casual development, albeit they shouldn't be as frequent. How much of the document is analyzed with every request? If there's an abnormally slow typist, they could see the same amount of CPU load as I'm currently seeing in Insiders. While the following isn't as bad as I've seen, just jotting down a few lines in small bursts normally wouldn't put a blip on resource monitors (even while the syntax highlighting updates as fast as possible).
I'll be glad to try out the same exercise when I can get the language features to use your commit. 👍
Martin Aeschlimann (@aeschli) Unfortunately, I'm still seeing a lot of busy throws. It's definitely better than it was, but I'm finding myself trying to race the 300ms to prevent CPU spikes. Every missed keystroke or pause to let variable/function suggestions populate results in my laptop quickly becomes a toaster. I know this is in part the nature of various features like IntelliSense and the like, but I could have sworn developing on VSCode from a few months ago did not burn through as many CPU cycles.
A couple things come to mind. Would it be simple to make the delay configurable, with 300ms being the default? And does the semantic tokens provider scan through the entire document during every request (or response)? Or is it only the current line(s) with an active cursor? The performance could be very different if it only tests the current lines for semantic differences.
Ben Arnett (@midnight-dev) Yes, currently the whole document is looked at. The next step is to switch to range based semantic highlighting. We'll try that first before making the delay configurable.
bugIssue identified by VS Code Team member as probable bugsemantic-tokensSemantic tokens issuestypescriptTypescript support issuesverifiedVerification succeeded
Activity
nathonius commentedon Mar 13, 2020
I'm seeing similar behavior, though restarting the TS server seemed to fix it for me temporarily. Also seeing #92652 , and restarting the TS server fixed that for me as well. However, on restarting VS Code, the problem comes back. It's inconsistent though.
Version: 1.44.0-insider (user setup)
Commit: efd7548
Date: 2020-03-13T06:05:25.782Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18362
mckn commentedon Mar 16, 2020
I'm seeing the same issue. But the following process spins up and takes more then 100% of the CPU.
/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer) --max-old-space-size=3072 /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/zd/0zb6dxm95s7_d0_vwt2_bfch0000gn/T/vscode-typescript501/2c14536d71655c3c603f/tscancellation-53c31963055dafeda08a.tmp* --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocationVersion: 1.43.0
Commit: 78a4c91
Date: 2020-03-09T19:34:44.548Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.3.0
nathonius commentedon Mar 16, 2020
I'm no longer seeing this behavior. Not sure if something was fixed in newer insiders releases or if it was just something temporal.
midnight-dev commentedon Mar 17, 2020
I can confirm this behavior while working on mostly JavaScript. At first I thought it was my poorly scoped monolithic JS file, (and I've been slowly losing my mind since Google and GitHub seemed to be unaware of such an issue a week ago).
Brief spec:
VSCode linting / IntelliSense for JavaScript breaks seemingly for every new token or expression typed until the TS language server recovers from a seizure. Simply undoing or redoing a few times will litter the extension host output with this while TS/JS server tries to unbork itself.
Extension host terminal output:
Typing out the following in any JavaScript file (on the latest stable version of VSCode) would result in 3 or 4 reinitializations for the language server:
Enabling logging or tracing doesn't point to an obvious suspect, though I don't have much experience reading those. No relevant results come up when searching through for the obvious "error", "fail", and "busy" keywords. I couldn't find "_provideSemanticTokens" either regardless of the level of verbosity. I'd include some samples, however, most of the code I'm working with is sensitive.
I'm not running with major changes. Using TypeScript 3.8.3 that VSCode comes with. Although I only see 40-60% CPU utilization for several seconds, this is making it a pain to get things done. Depending on the size of the JavaScript file open, IntelliSense seems to take longer to show up and syntax highlighting sometimes decides it should re-render. Anything except reading or scrolling through JavaScript now thrashes my CPU cores. Increasing the memory allowance to the TS server from the default of 3072 MiB to 4096 MiB did not help, and I couldn't find any settings relating to time thresholds.
Disabling all extensions (except built-ins) does not change this behavior. The size of the file doesn't seem to matter. Manually restarting the TS server does not actually help in my case. All it seems to do is quiet down the UI notification that the server features are rebooting. The laggy UX / linting / IntelliSense symptoms are still present and the ext host logs still come up with busy / fail errors.
Apologies for creating a wall of text, but I'm hoping this will help someone quickly submit a fix. Here is where the ext host error points to (formatted for readability).
Even when still minified, the column 180337 isn't too useful, as it points to somewhere in the middle of
new r.SemanticTokensBuilderbut since the only error is "busy," I'd say it's probably trying to point at this, which does raise an eyebrow:If
eis passed in and never mutated, andiis set toe.versionand then later checked for that exact match, how can it not be equal to it? Since this check exists, I guess it has something to do with state and is expected behavior here. Hope this helps. If it's already fixed in Insiders, I'd greatly appreciate a hotfix for those of us still on stable.Edit: Fixed typo
midnight-dev commentedon Mar 21, 2020
Update:
Upon installing version 1.43.1, I still noticed a TypeScript failure/busy error when typing or modifying tokens. I disabled semantic highlighting globally, and the failures stopped. The insane amount of CPU thrashing also stopped.
This seems like a useful feature to have, but it's broken due to a busy timeout when some conditions are met. For people working on powerful workstations, they may not even notice it if the TypeScript language server reboots fast enough. With my settings and my JavaScript projects, it makes developing too difficult. The language features shouldn't crash every 4 seconds anyway. If anyone knows of a setting that might resolve the busy issues with semantic highlighting, please point me in the right direction.
mckn commentedon Mar 23, 2020
Ben Arnett (@midnight-dev) will give that a try, thanks! Will get back here with a report.
aeschli commentedon Mar 26, 2020
I don't see any crashes, but I can confirm that while typing are a lot of semantic token requests fired and most of them discarded ('busy') for medium and large files.
I can imagine that adds considerable load on the TS language server and explain what Ben Arnett (@midnight-dev) is seeing.
Alexandru Dima (@alexdima), Can we throttle the requests until typing has ended?
Also, the error message printed to the ext host log is misleading
midnight-dev commentedon Mar 26, 2020
I'd like to second that request. Also, does the semantic tokens provider scan through the entire document every time it updates the semantic tokens? If so, it would greatly improve performance if it only parsed the line(s) with an active cursor.
6 remaining items
aeschli commentedon Mar 29, 2020
What's special here is that editor doesn't throttle, always sends right after a change, but never sends more than one request. It waits for the last request to return until it fires the next.
Knowing that, he provider takes a chance, ask the LS right away. If it turns out to be the only change, the result can be given back to the editor without any delay. If at the time of the response we see that the document has changed, we wait until the activity has stopped before telling the server that we failed.
The server will then make a request right away.
At least that's the idea, I hope I haven't overlooked anything. I also normally do it the other way around.
alexdima commentedon Mar 29, 2020
Initially, the semantic tokens request would be created 500ms after typing stopped. But in #86165 the complaint is that strategy makes semantic tokens update very slowly, making semantic tokens appear laggy.
So with the changes for #86165, the request is created 300ms after the first typing, then the request is waited for, and then a new request is made if typing occurred again in the meantime, thus the rate is at most 1 every 300ms. I believe this is a sensible upper bound.
The error is logged from here, that generic piece of code does not know about the special semantic of
busyerrors. Rather than teaching that piece of code aboutbusyerrors, I have created #93686 to track that we introduce a special error type invscode.d.tsand that can be instance checked and ignored for logging.aeschli commentedon Mar 29, 2020
Marking as fixed.
Ben Arnett (@midnight-dev) Please give it a try.
midnight-dev commentedon Mar 29, 2020
Martin Aeschlimann (@aeschli) Is there a relatively painless way to get VSCode to use this new commit since it's ultimately just a piece of the TS language server? If not, I may have to wait for Insiders to catch up. It's currently on commit 6cf3dd9 from earlier in the week.
I'm still a bit worried that there will be CPU spikes during normal, even casual development, albeit they shouldn't be as frequent. How much of the document is analyzed with every request? If there's an abnormally slow typist, they could see the same amount of CPU load as I'm currently seeing in Insiders. While the following isn't as bad as I've seen, just jotting down a few lines in small bursts normally wouldn't put a blip on resource monitors (even while the syntax highlighting updates as fast as possible).
I'll be glad to try out the same exercise when I can get the language features to use your commit. 👍
connor4312 commentedon Apr 3, 2020
Martin Aeschlimann (@aeschli) are there verification steps for this?
aeschli commentedon Apr 3, 2020
To verify
midnight-dev commentedon Apr 8, 2020
Martin Aeschlimann (@aeschli) Unfortunately, I'm still seeing a lot of busy throws. It's definitely better than it was, but I'm finding myself trying to race the 300ms to prevent CPU spikes. Every missed keystroke or pause to let variable/function suggestions populate results in my laptop quickly becomes a toaster. I know this is in part the nature of various features like IntelliSense and the like, but I could have sworn developing on VSCode from a few months ago did not burn through as many CPU cycles.
A couple things come to mind. Would it be simple to make the delay configurable, with 300ms being the default? And does the semantic tokens provider scan through the entire document during every request (or response)? Or is it only the current line(s) with an active cursor? The performance could be very different if it only tests the current lines for semantic differences.
aeschli commentedon Apr 9, 2020
Ben Arnett (@midnight-dev) Yes, currently the whole document is looked at. The next step is to switch to range based semantic highlighting. We'll try that first before making the delay configurable.