Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Terminal Hangs when attaching to PowerShell 5.1

Aberta
#1,369 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
csharp, powershell
Domínio
devtools

Direção de pesquisa

Comece reproduzindo o travamento com Enter-PSHostProcess no PowerShell 5.1 e, em seguida, inspecione PowerShellContextService.cs nas proximidades de ExecuteCommandAsync na linha 778 e o tratamento de Get-Runspace e Debug-Runspace. Considera-se concluído quando os comandos emitidos após a conexão continuam responsivos no PowerShell 5.1, enquanto o comportamento existente do PowerShell 7 continua funcionando.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Area-Debugging Issue-Bug

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.

image

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.

Linguagem predominante
C#
Estrelas
767
Forks
266
Merge médio
3d 16h
PRs com merge (30d)
1

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de PowerShell/PowerShellEditorServices

Todas as issues de PowerShell/PowerShellEditorServices

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.