PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items/ms-vscode.PowerShell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$Host.PushRunspace with a local runspace kills the terminal

MartinGC94 opened this issue · comments

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Trying to run the following:

$NewRunspace = [runspacefactory]::CreateRunspace()
$NewRunspace.Open()
$Host.PushRunspace($NewRunspace)

Will cause the terminal to rapidly write out error messages with no way to stop it without killing the terminal.

I don't expect this to work, but it should throw a notsupported error and recover if I try to do something that isn't supported.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0-preview.1
PSEdition                      Core
GitCommitId                    7.5.0-preview.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2024.3.0
InstanceId       : b64cd44e-851c-4783-aa4e-b24d4d5cfeae
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : da-DK
CurrentUICulture : da-DK
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.87.0-insider
ec291c126878742ad640055ce604a58129cd088c
x64

Extension Version

ms-vscode.powershell@2024.3.0

Steps to Reproduce

Paste the code from above into the terminal

Visuals

No response

Logs

No response

Yeah makes sense. I think ConsoleHost in PowerShell also needs a check, it just happens to fail due to an NRE iirc