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
Delays in running PowerShell code or F8 not working at all #1769
When selecting PowerShell code in Visual Studio Code and running it either via right click -> Run Selection or by pressing F8, it sometimes takes a long time for the code to run and sometimes it doesn't run at all, whereas other moments (rarely unfortunately) the code runs straight away. There is no other keybinding to F8. It doesn't matter how much code is selected either. It can be as little as: $test = 'Test'. I have hardly any modules loaded; the default Windows modules, AzureRM and AzureAD. I have tried with ScriptAnalyzer disabled ("powershell.scriptAnalysis.enable": false), but that didn't help. The issue is so bad currently, that I just copy/paste the code into the integrated PowerShell window to run it, which works fine, but which is a pain when you need to run parts which consist of multiple lines of code.
Thanks for reporting this @atyourservers ! It would be really helpful if you could provide logs if this happens again so that we can better diagnose the issues--instructions for how to do this are here
Sydney Smith (@SydneyhSmith) please find the logs attached. I had to redact them quite a bit. Tested it with some test files. Started around 9:20 until 9:35, then had some calls and if I remember correctly, I later tried to run a few more commands, closed everything, redacted the logs and here you go. The issue occurred various times, so hopefully the logs are helpful. Looking forward to hearing from you.
@atyourservers thanks for providing the logs that always helps! There is nothing obvious about your environment that would be causing issues but we have had other reports of performance issues that we are hoping to solve soon and this is likely related.
When I just paste code in the integrated PowerShell window it runs straight. It only happens when I try to execute code from the editor window by pressing F8 or via right click -> Run Selection. It's like there is a process of some sort which tries to do something to the code, such as validation, which takes minutes to run. I thought this could be the ScriptAnalyzer, but disabling it didn't have any effect on the issue. Seeing that it sometimes does work fine for a few minutes maximum, it's like a process gets stuck sometimes in the background. More people here are experiencing the same issue. I love Visual Studio Code and the PowerShell extension, but this issue is forcing us to use different tools. Hopefully it can be tackled soon.
@atyourservers some people have had success with associating performance issues to code lens, disabling that might be something worth trying. More likely this is due to architectural challenges that we are hoping to resolve soon.
I've had this same issue for at least a year with VS Code. As I type this, I'm waiting for an F8 command to run:
$date = get-date
It's been nearly 10 minutes, so now I'm going to have to close and re-open the terminal window, losing all of the content in memory that I've been working on. This happens at least once a day.
It is incredibly frustrating that this software is so unstable while also being touted as the obvious replacement for PowerShell ISE. ISE has been very stable since 1.0.
@atyourservers Looking at your log file, it seems that SymbolReference CodeLens comand resolve results are taking a long time but those requests are supposed to run async (in another runspace) and return results "out-of-band":
The codeLens/resolve for symbol references appears to run synchronously - blocking all other LSP messages until the CA request finishes. These are consecutive LSP JsonRpc request/response messages pairs. Check out the timestamp diffs:
There is a 1 min 40 sec gap between index 47 and 48. There is a 2 min 35 sec gap between index 53 and 54. Index 53 indicates script analysis has finished but it doesn't get a chance to send VSCode the diagnosit results until index 1109, almost three minutes later.
This is also puzzling, we get the request to resolve the codelens command here and begin symbol reference analysis:
So the question is, why the gap? Does this have something to do with the file being on the u: drive? Or maybe the code analysis causes some sort of deadlock? Any ideas Rob Holt (@rjmholt)?
BTW the message from index 47 comes from the Workspace.GetFile() call in HandleCodeLensResolveRequestAsync and just a few lines later we enter into the ResolveCodeLensProvider.ResolveCodeLensAsync() method which eventually returns a result at index 1106 ~5 minutes later.
I would just like to add, I have been running with codelens disabled for over a year #1326
I still see performance issues, . . . and freezes. . . I can repro this 100% of the time.
I will have to also add/try: "powershell.scriptAnalysis.enable": false
At this stage, we have no formatting or code analysis in the extension... so hopefully we can find the root cause of these issue, since they are tools that we would prefer to have enabled. . . This is an ongoing issue, since Code/PS Extension was first released.
Ben Wilkinson (@brwilkinson) The code analysis perf issues are due to PSScriptAnalyzer perf. There is a release coming out of PSSA that will improve the perf of PSSA. There is also a PR that Glenn Sarti (@glennsarti) is working on that will reduce the scope of files being analyzed for symbol references. That should help some as well. If you are running into perf issues with both code lens and code analysis disabled, please attach log files. That is our primary way to track the root cause of perf issues unless we have solid way to repro perf issues.
Ben Wilkinson (@brwilkinson) Can you update to the latest 1.18.0 release of PSScriptAnalyzer and re-enable codeAnalysis. This version of PSSA is significantly more performant.
It's still a definite no for Codelens. . . however for now with that disabled and psscriptanalyzer updated the following are working pretty well . . .
Formatting is fast
ScriptAnalyzer rules process fast
F8 actually works . . . without delays 😁
Intellisense actually works . . . with only a very minor delay on the very first time you use it on a function. I haven't seen this before at all. . so that is amazing. . .
I'll provide another update once I actually write some proper code, rather than just running some code and tests. . . however there is definitely a major improvement without any doubt.
Thanks for the feedback. Yeah, I wouldn't expect any change for the reference code lens as that is implemented separately. I think there will be a feature in the next version to allow you to exclude folders from reference analysis. That might help if you have dirs (like output or import dirs) that don't need to be analyzed.
Activity
SydneyhSmith commentedon Feb 21, 2019
Thanks for reporting this @atyourservers ! It would be really helpful if you could provide logs if this happens again so that we can better diagnose the issues--instructions for how to do this are here
arievanderwende commentedon Feb 22, 2019
Sydney Smith (@SydneyhSmith) please find the logs attached. I had to redact them quite a bit. Tested it with some test files. Started around 9:20 until 9:35, then had some calls and if I remember correctly, I later tried to run a few more commands, closed everything, redacted the logs and here you go. The issue occurred various times, so hopefully the logs are helpful. Looking forward to hearing from you.
logs.zip
SydneyhSmith commentedon Feb 26, 2019
@atyourservers thanks for providing the logs that always helps! There is nothing obvious about your environment that would be causing issues but we have had other reports of performance issues that we are hoping to solve soon and this is likely related.
arievanderwende commentedon Feb 28, 2019
When I just paste code in the integrated PowerShell window it runs straight. It only happens when I try to execute code from the editor window by pressing F8 or via right click -> Run Selection. It's like there is a process of some sort which tries to do something to the code, such as validation, which takes minutes to run. I thought this could be the ScriptAnalyzer, but disabling it didn't have any effect on the issue. Seeing that it sometimes does work fine for a few minutes maximum, it's like a process gets stuck sometimes in the background. More people here are experiencing the same issue. I love Visual Studio Code and the PowerShell extension, but this issue is forcing us to use different tools. Hopefully it can be tackled soon.
SydneyhSmith commentedon Feb 28, 2019
@atyourservers some people have had success with associating performance issues to code lens, disabling that might be something worth trying. More likely this is due to architectural challenges that we are hoping to resolve soon.
Mike-Crowley commentedon Mar 1, 2019
I've had this same issue for at least a year with VS Code. As I type this, I'm waiting for an F8 command to run:
$date = get-date
It's been nearly 10 minutes, so now I'm going to have to close and re-open the terminal window, losing all of the content in memory that I've been working on. This happens at least once a day.
It is incredibly frustrating that this software is so unstable while also being touted as the obvious replacement for PowerShell ISE. ISE has been very stable since 1.0.
rkeithhill commentedon Mar 3, 2019
@atyourservers Looking at your log file, it seems that SymbolReference CodeLens comand resolve results are taking a long time but those requests are supposed to run async (in another runspace) and return results "out-of-band":
The
evaluateis executing:Does this correspond to one of your lengthy F8 atttempts?
BTW the evaluate above that takes ~88 secs shows how this request is executed async:
rkeithhill commentedon Mar 3, 2019
The codeLens/resolve for symbol references appears to run synchronously - blocking all other LSP messages until the CA request finishes. These are consecutive LSP JsonRpc request/response messages pairs. Check out the timestamp diffs:
Between index 46 and 1106, we seem to be opening a lot of files:
There is a 1 min 40 sec gap between index 47 and 48. There is a 2 min 35 sec gap between index 53 and 54. Index 53 indicates script analysis has finished but it doesn't get a chance to send VSCode the diagnosit results until index 1109, almost three minutes later.
This is also puzzling, we get the request to resolve the codelens command here and begin symbol reference analysis:
but then there are only code analysis messages:
Then after than 2 min 35 sec gap, we start back with the symbol reference analysis:
So the question is, why the gap? Does this have something to do with the file being on the
u:drive? Or maybe the code analysis causes some sort of deadlock? Any ideas Rob Holt (@rjmholt)?BTW the message from index 47 comes from the
Workspace.GetFile()call inHandleCodeLensResolveRequestAsyncand just a few lines later we enter into theResolveCodeLensProvider.ResolveCodeLensAsync()method which eventually returns a result at index 1106 ~5 minutes later.9 remaining items
brwilkinson commentedon Mar 16, 2019
I would just like to add, I have been running with codelens disabled for over a year #1326
I still see performance issues, . . . and freezes. . . I can repro this 100% of the time.
I will have to also add/try: "powershell.scriptAnalysis.enable": false
At this stage, we have no formatting or code analysis in the extension... so hopefully we can find the root cause of these issue, since they are tools that we would prefer to have enabled. . . This is an ongoing issue, since Code/PS Extension was first released.
rkeithhill commentedon Mar 16, 2019
Ben Wilkinson (@brwilkinson) The code analysis perf issues are due to PSScriptAnalyzer perf. There is a release coming out of PSSA that will improve the perf of PSSA. There is also a PR that Glenn Sarti (@glennsarti) is working on that will reduce the scope of files being analyzed for symbol references. That should help some as well. If you are running into perf issues with both code lens and code analysis disabled, please attach log files. That is our primary way to track the root cause of perf issues unless we have solid way to repro perf issues.
brwilkinson commentedon Mar 16, 2019
Thanks Keith Hill (@rkeithhill) . . .
I am trying out: "powershell.scriptAnalysis.enable": false . . . for now and will share any feedback...
I'll keep an eye on the updates. . .
brwilkinson commentedon Mar 16, 2019
okay disabling 'scriptAnalysis' definitely helps . . . however the freezes have not gone all together.
I will share some more logs here...
rkeithhill commentedon Mar 22, 2019
Ben Wilkinson (@brwilkinson) Can you update to the latest 1.18.0 release of PSScriptAnalyzer and re-enable codeAnalysis. This version of PSSA is significantly more performant.
brwilkinson commentedon Mar 22, 2019
Thanks Keith Hill (@rkeithhill) I have installed 1.18.0, will give it a run. . . keep you posted.
brwilkinson commentedon Mar 22, 2019
Keith Hill (@rkeithhill) Looking good so far. . . Thank you. . .
It's still a definite no for Codelens. . . however for now with that disabled and psscriptanalyzer updated the following are working pretty well . . .
I'll provide another update once I actually write some proper code, rather than just running some code and tests. . . however there is definitely a major improvement without any doubt.
rkeithhill commentedon Mar 22, 2019
Thanks for the feedback. Yeah, I wouldn't expect any change for the reference code lens as that is implemented separately. I think there will be a feature in the next version to allow you to exclude folders from reference analysis. That might help if you have dirs (like output or import dirs) that don't need to be analyzed.
SydneyhSmith commentedon May 24, 2019
Going to close this as a duplicate of #1326
tropez1971 commentedon Sep 28, 2020
I tried disabling CodeLens, issue still persists.