vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

$Host.PushRunspace with a local runspace kills the terminal

Open MartinGC94 opened this issue 1 year ago • 1 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all open and closed issues to ensure it has not already been reported.
  • [X] I have read the troubleshooting guide.
  • [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • [X] 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

[email protected]

Steps to Reproduce

Paste the code from above into the terminal

Visuals

No response

Logs

No response

MartinGC94 avatar Feb 16 '24 11:02 MartinGC94

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

SeeminglyScience avatar Feb 21 '24 18:02 SeeminglyScience