Terminal Hangs when attaching to PowerShell 5.1
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza reproduciendo el bloqueo con Enter-PSHostProcess contra PowerShell 5.1 y, a continuación, inspecciona PowerShellContextService.cs alrededor de ExecuteCommandAsync en la línea 778 y el tratamiento de Get-Runspace y Debug-Runspace. Se considera terminado cuando los comandos ejecutados después de conectarse siguen respondiendo en PowerShell 5.1 y el comportamiento existente de PowerShell 7 continúa funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
We have a feature of the PowerShell Universal extension where we allow you to connect to the PowerShell process running the dashboard script. This works by simply calling Enter-PSHostProcess in the PowerShell Integrated Terminal.
Once connected, you can then use Get-Runspace and Debug-Runspace to attach and debug the runspaces in question. This works well and opens a PS1 file and breaks after a Wait-Debugger call.
What doesn't work is that after we've attached, if you attempt to issue a command in the terminal, it hangs.

It doesn't hang when connecting to PowerShell 7. It does hang when connecting to PowerShell 5.1.
I don't know if these are related at all but there are some errors in the log. I reproduced this around 10:30 AM so the last two errors may be relevant.
[Info - 08:41:35] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: PowerShell runtime version: 7.0.3, edition: Core |
[Info - 08:41:35] Microsoft.PowerShell.EditorServices.Handlers.PsesDocumentHighlightHandler: highlight handler loaded |
[Error - 09:00:58] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Execution of the following command(s) completed with errors:
invoke-build buildserverdeploy -Configuration debug
Out-Default
|
[Warn - 09:00:58] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Runtime exception occurred while executing command:
System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path 'C:\src\universal\src\output\runtimes' because it does not exist.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.<>c__DisplayClass89_0`1.<ExecuteCommandAsync>b__0() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 778
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 778
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 823 |
[Error - 09:28:43] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Execution of the following command(s) completed with errors:
invoke-build buildserverdeploy -Configuration debug
Out-Default
|
[Warn - 09:28:43] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Runtime exception occurred while executing command:
System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path 'C:\src\universal\src\output\runtimes' because it does not exist.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.<>c__DisplayClass89_0`1.<ExecuteCommandAsync>b__0() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 778
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 778
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 823 |
[Info - 09:35:22] Microsoft.PowerShell.EditorServices.Services.AnalysisService: Unable to find PSSA settings file at 'c:\src\universal\PSScriptAnalyzerSettings.psd1'. Loading default rules. |
[Info - 09:35:22] Microsoft.PowerShell.EditorServices.Services.AnalysisService: PSScriptAnalyzer settings file not found. Falling back to default rules |
[Error - 10:34:57] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Execution of the following command(s) completed with errors:
Microsoft.PowerShell.Core\Get-Command New-PSUDashboard -ErrorAction Ignore
|
[Error - 10:35:02] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Execution of the following command(s) completed with errors:
Microsoft.PowerShell.Core\Get-Command New-PSUDashboard -ErrorAction Ignore
|
The VS Code log looks clean.
14/10/2020 08:41:24 [NORMAL] - Visual Studio Code v1.50.0 64-bit
14/10/2020 08:41:24 [NORMAL] - PowerShell Extension v2020.6.0
14/10/2020 08:41:24 [NORMAL] - Operating System: Windows 64-bit
14/10/2020 08:41:24 [NORMAL] - Language server starting --
14/10/2020 08:41:24 [NORMAL] - PowerShell executable: C:\Program Files\PowerShell\7\pwsh.exe
14/10/2020 08:41:24 [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules' -EnableConsoleRepl -StartupBanner "=====> PowerShell Integrated Console v2020.6.0 <=====
" -LogLevel 'Normal' -LogPath 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\logs\1602686484-0f43eafb-f01a-48c5-9945-888347f8f8b71602686475858\EditorServices.log' -SessionDetailsPath 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\sessions\PSES-VSCode-10732-427343' -FeatureFlags @()
14/10/2020 08:41:24 [NORMAL] - PowerShell Editor Services args: Import-Module 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\modules' -EnableConsoleRepl -StartupBanner "=====> PowerShell Integrated Console v2020.6.0 <=====
" -LogLevel 'Normal' -LogPath 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\logs\1602686484-0f43eafb-f01a-48c5-9945-888347f8f8b71602686475858\EditorServices.log' -SessionDetailsPath 'c:\Users\adamr\.vscode\extensions\ms-vscode.powershell-2020.6.0\sessions\PSES-VSCode-10732-427343' -FeatureFlags @()
14/10/2020 08:41:24 [NORMAL] - pwsh.exe started.
14/10/2020 08:41:24 [NORMAL] - Waiting for session file
14/10/2020 08:41:33 [NORMAL] - Session file found
14/10/2020 08:41:33 [NORMAL] - Registering terminal close callback
14/10/2020 08:41:33 [NORMAL] - Registering terminal PID log callback
14/10/2020 08:41:33 [NORMAL] - pwsh.exe PID: 23676
14/10/2020 08:41:33 [NORMAL] - Language server started.
14/10/2020 08:41:33 [NORMAL] - {"status":"started","languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_0qvw0oh4.1xl","debugServiceTransport":"NamedPipe","debugServicePipeName":"\\\\.\\pipe\\PSES_jyeuyt2z.21h"}
14/10/2020 08:41:33 [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_0qvw0oh4.1xl...
14/10/2020 08:41:33 [NORMAL] - Language service connected.
Let me know if you need any more info.
- Lenguaje dominante
- C#
- Estrellas
- 767
- Forks
- 266
- Merge medio
- 3 d 16 h
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PowerShell/PowerShellEditorServices
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. Abierto
PowerShell/PowerShellEditorServices#2331 · 1 reacción · 2 asignados ·
-
Area-Language Server Issue-Enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
PowerShell/PowerShellEditorServices#2315 · 1 comentario ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 reacción · 2 asignados ·
-
Issue-Bug Needs: Triage
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
PowerShell/PowerShellEditorServices#2293 · 1 comentario ·
-
PowerShell/PowerShellEditorServices#2282 · 1 comentario · 1 reacción · 2 asignados ·
Todos los issues de PowerShell/PowerShellEditorServices
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
nightscout/nocturne#1425 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
cake-build/cake#5024 ·
-
Gå gjennom ESLint-suppressions AbiertoFrontend status/draft TechnicalDebt
Dificultad 2/5 1-2 días Aptitud para principiantes 75/100
Altinn/altinn-auth#4143 ·