Errors thrown when querying for available commands cause no commands to be shown
@andyleejordan đang làm issue này rồi.
Từ ngày 20/5/2021.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Version : 2021.2.2
This all started when I noticed that the command explorer was blank - never seeming to load the list of available commands.
In the console there was an error like this :
/C:/Users/chgagnon/AppData/Local/Programs/Azure Data Studio - Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2759 Error: Internal Error - System.Management.Automation.ParseException: At C:\Users\chgagnon\AppData\Local\Yarn\bin\tsc.ps1:5 char:13
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+ ~
Unexpected token ')' in expression or statement.
At C:\Users\chgagnon\AppData\Local\Yarn\bin\tsc.ps1:8 char:3
+ if [ -x "$basedir/pwsh" ]; then
+ ~
Missing '(' after 'if' in if statement.
At C:\Users\chgagnon\AppData\Local\Yarn\bin\tsc.ps1:8 char:5
+ if [ -x "$basedir/pwsh" ]; then
+ ~
Missing type name after '['.
At C:\Users\chgagnon\AppData\Local\Yarn\bin\tsc.ps1:9 char:20
+ ... sedir/pwsh" "$basedir/../Data/global/node_modules/.bin/tsc.ps1" "$@"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"$basedir/../Data/global/node_modules/.bin/tsc.ps1"' in expression or statement.
At C:\Users\chgagnon\AppData\Local\Yarn\bin\tsc.ps1:9 char:72
+ ... sedir/pwsh" "$basedir/../Data/global/node_modules/.bin/tsc.ps1" "$@"
+ ~~~~
Unexpected token '"$@"' in expression or statement.
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ExternalScriptInfo.ParseScriptContents(Parser parser, String fileName, String fileContents, Nullable`1 definingLanguageMode)
at System.Management.Automation.ExternalScriptInfo.get_ScriptBlock()
at System.Management.Automation.ExternalScriptInfo.get_CommandMetadata()
at System.Management.Automation.CommandInfo.GenerateCommandParameterSetInfo()
at System.Management.Automation.CommandInfo.get_ParameterSets()
at Microsoft.PowerShell.EditorServices.Handlers.GetCommandHandler.<Handle>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.<Handle>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.<Handle>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MediatR.Pipeline.RequestPreProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MediatR.Pipeline.RequestPostProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<<RouteRequest>g__InnerRoute|5_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass38_0.<<RouteRequest>b__5>d.MoveNext()
at handleResponse (c:\Users\chgagnon\.azuredatastudio-insiders\extensions\ms-vscode.powershell-2021.2.2\node_modules\vscode-jsonrpc\lib\common\connection.js:477:48)
at processMessageQueue (c:\Users\chgagnon\.azuredatastudio-insiders\extensions\ms-vscode.powershell-2021.2.2\node_modules\vscode-jsonrpc\lib\common\connection.js:292:17)
at Immediate.<anonymous> (c:\Users\chgagnon\.azuredatastudio-insiders\extensions\ms-vscode.powershell-2021.2.2\node_modules\vscode-jsonrpc\lib\common\connection.js:276:13)
at processImmediate (internal/timers.js:456:21)
The important part being here :
at System.Management.Automation.ScriptBlock.Create(Parser parser, String fileName, String fileContents)
at System.Management.Automation.ExternalScriptInfo.ParseScriptContents(Parser parser, String fileName, String fileContents, Nullable`1 definingLanguageMode)
at System.Management.Automation.ExternalScriptInfo.get_ScriptBlock()
at System.Management.Automation.ExternalScriptInfo.get_CommandMetadata()
at System.Management.Automation.CommandInfo.GenerateCommandParameterSetInfo()
at System.Management.Automation.CommandInfo.get_ParameterSets()
at Microsoft.PowerShell.EditorServices.Handlers.GetCommandHandler.<Handle>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
This error stack is from the Powershell language service and specifically when it was handling the powershell/getCommand message : https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetCommandHandler.cs#L79
The file in question seems to be coming from npm : https://github.com/npm/cmd-shim/blob/master/index.js
And indeed on my system I have a tsc.ps1 file that contains what appears to be a bash script :
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/pwsh" ]; then
"$basedir/pwsh" "$basedir/../Data/global/node_modules/.bin/tsc.ps1" "$@"
ret=$?
else
pwsh "$basedir/../Data/global/node_modules/.bin/tsc.ps1" "$@"
ret=$?
fi
exit $ret
(interesting note, I also have a tsc.ps1.ps1 that contains an actual powershell script. So it looks like this might be an issue with how they generate these scripts instead on Windows machines.
Once I removed the scripts in question then everything worked and the command list populated.
Suggested Fix
While it definitely seems like a bug that they're generated this invalid ps1 file I think we should also be catching and ignoring errors that happen while trying to get the metadata from a command. So in this foreach : https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetCommandHandler.cs#L61 it we just wrapped the entire inner block in a try/catch then we could just ignore any errors that happen while parsing commands so that a single bad "command" doesn't break the entire feature.
- Ngôn ngữ chính
- C#
- Star
- 767
- Fork
- 266
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PowerShell/PowerShellEditorServices
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. Đang mở
PowerShell/PowerShellEditorServices#2331 · 1 reaction · 2 người được giao ·
-
Area-Language Server Issue-Enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
PowerShell/PowerShellEditorServices#2315 · 1 bình luận ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 reaction · 2 người được giao ·
-
Issue-Bug Needs: Triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
PowerShell/PowerShellEditorServices#2293 · 1 bình luận ·
-
PowerShell/PowerShellEditorServices#2282 · 1 bình luận · 1 reaction · 2 người được giao ·
Tất cả issue của PowerShell/PowerShellEditorServices
Issue tương tự
-
Documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cake-build/cake#5024 ·
-
Gå gjennom ESLint-suppressions Đang mởFrontend status/draft TechnicalDebt
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 75/100
Altinn/altinn-auth#4143 ·
-
.NET Flaky Test Testing Tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
getsentry/sentry-dotnet#5617 · 1 bình luận ·
-
Add more to the documentation Đang mở:watch: Not Triaged dotnet-fsharp/svc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Azure/azure-sdk-for-net#63292 · 3 bình luận · 1 reaction ·