Vscode-powershell: [2021.4.1-preview] Unusual Control Characters In SSH Session

Created on 8 Apr 2021  Â·  18Comments  Â·  Source: PowerShell/vscode-powershell

Issue Type: Bug

ANSI escape characters show up in SSH remoting sessions in integrated console.

  • Does not happen in dedicated terminal (non-integrated)
  • Downgrading to 2021.2.1 seems to resolve the issue however it is intermittent and not readily reproducible, seems to occur when a lot of text is scrolled across the terminal at once.

Capture

Also observed here:
https://twitter.com/Phatmandrake/status/1380171258998980612

Extension version: 2021.2.1
VS Code version: Code - Insiders 1.56.0-insider (bb90ba3d5a5f8d114045b045f3bbe1ebc404f54a, 2021-04-07T12:30:14.880Z)
OS version: Windows_NT x64 10.0.19043
Fetching remote diagnostics for 'ssh-remote+tinycloud' timed out.
Remote OS version: Linux x64 5.4.0-66-generic


System Info

|Item|Value|
|---|---|
|CPUs|AMD Ryzen 7 4700U with Radeon Graphics (8 x 1996)|
|GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.37GB (3.14GB free)|
|Process Argv|--folder-uri file:///c%3A/Users/JGrote/Projects/Press --crash-reporter-id 4453efaa-0821-4555-88e2-3de8bad9109e|
|Screen Reader|no|
|VM|0%|

Fetching remote diagnostics for 'ssh-remote+tinycloud' timed out.

|Item|Value|
|---|---|
|Remote|SSH: tinycloud|
|OS|Linux x64 5.4.0-66-generic|
|CPUs|Intel(R) Xeon(R) CPU E5-2695 v2 @ 2.40GHz (4 x 2399)|
|Memory (System)|4.33GB (0.81GB free)|
|VM|0%|


A/B Experiments

vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30244315
pythonvsdeb440:30224570
pythonvsded773:30223139
pythonvspyt875:30259475
pythonvsnew554:30265444
pythontb:30258533
wslfolderdoccf:30278406
vsget980:30283264
vspre833cf:30267465
pythonptprofiler:30281269
vscnewfiletext:30280636
vshan820cf:30276953
pythondataviewer:30285072
vscus158cf:30286554

Area-Integrated Console Issue-Bug Needs-Repro-Info Resolution-External vscode-bug

Most helpful comment

Thanks to @Tyriar there is a workaround https://github.com/microsoft/vscode/issues/120352#issuecomment-817816959 while this bug is being investigated:

"terminal.integrated.localEchoLatencyThreshold": -1

All 18 comments

Thanks @JustinGrote for opening this issue.....what command did you use to initiate the SSH remoting?
@daxian-dbw and @PaulHigin in case either of you have any ideas as to what may be occurring here...

@SydneyhSmith just normal connect to host with vscode SSH remoting. Nothing in the logs looks out of place.

And before you ask I tried without my custom prompt as well, it still happens, additional reproduction in the twitter link from someone else who had the problem in a non-SSH environment (I believe) :)

Related: https://github.com/microsoft/vscode/issues/120352

I've also been experiencing this for the last few weeks.

Just today I was able to get it to surprisingly stop and regain control of the console.

The circumstances for how it starts in the first place though are still a bit of mystery, but generally speaking it occurs for me after I've executed "a lot" of arbitrary commands in the Integrated Terminal.

Then it seems to be triggered when I hit the Up Arrow or if I try to ctl+c.

If it's the Up Arrow key only a little bit of text is output. If I ctl+c a lot of text seems to be generated.

In either case, a combination of pressing the left, up, and down arrow keys, in no immediately discernible number of occurrences or order will cause it to stop.

When it does finally stop. I have to delete all the randomly generated characters from the current line and then Clear-Host to regain control of the console. Failure to do this will result in it starting again. I'll get a video if I can.

I am having the same issue while using production VSCode and my Ubuntu 20.04 WSL2 session.

Similar to what @phatmandrake said; the issue appears to occur after using a combination of the home or end keys, the left/right arrow keys, and CTRL+C

VSCode details:

Version: 1.55.0 (user setup)
Commit: c185983a683d14c396952dd432459097bc7f757f
Date: 2021-03-30T16:01:55.261Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042

This feels like a PSReadline issue, @daxian-dbw

many ppl complaining about similar related or even who knows the same bug... maybe is wsl remote extension, maybe not, maybe also... weeks...

ppl relates in stable and insider...

i personally tried pwsh preview and backed to stable, but not changed at all

p.s.: non related to the topic... but funny enough there are months that npm community are filled with threads about npm not updating version on package, but updating files... what a mess!!! but yarn also does that... maybe something in nodejs was broken by 3 months?

@JustinGrote By "SSH session", do you mean when working with a remote machine in VS Code by using the "Remote - SSH" VS code extension? Or do you mean when you run ssh from the local terminal to a remote machine?

It's not clear if "remoting" is a necessity to surface this issue. https://github.com/microsoft/vscode/issues/120352 doesn't clarify if the debugging was done locally or in a "Remote - SSH" session.

But at any rate, text being "automatically entered" means the terminal is sending stuff out and thus Console.ReadKey returns with those keystrokes. So, the question is what caused the terminal to send those sequences?

Also, did this only start to happen recently? Only specific to VS Code terminal? So far I don't see a similar report in PSReadLine and PowerShell repos.

@daxian-dbw based on the other repros I can't tell if it is remoting specific, but I haven't been able to reproduce in my local powershell integrated console, it only happened to me when using the Remote -SSH vscode extension and only in the integrated console, not in a spawned "external" powershell terminal, but I don't have a consistent way to reproduce yet. Others stated it happens with the up/down arrows so I figured something with history or related to the predictive intellisense might have been introduced.

Then it seems to be triggered when I hit the Up Arrow or if I try to ctl+c.
If it's the Up Arrow key only a little bit of text is output. If I ctl+c a lot of text seems to be generated.

The Ctrl+c behavior described by @phatmandrake is particularly strange. Would be great if we can have a consistent repro.

@daxian-dbw I was also able to reproduce the issue using ubuntu 20.04 + WSL 1 on a machine that had never had VSCode installed before.

Steps Taken:

  1. Download and install user version of VSCode on a machine with Ubuntu 20.04 WSL (version doesnt appear to matter) + PWSH pre-installed.
  2. Open VSCode and download "Remote - WSL" code extension.
  3. Command Pallete -> Remote WSL: New Window
  4. Install Powershell Extension (v2021.2.2) in WSL VSCode session.
  5. Close/Re-open VSCode
  6. Wait for pwsh integrated terminal to launch
  7. Entered "#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" at the pwsh prompt (including quotes) and hit enter.
  8. Hit Up Arrow, Left Arrow, Left Arrow, Home, CTRL + C

typing "a" and clicking trash on the window also crashes the PTY handler (see https://github.com/PowerShell/vscode-powershell/issues/3281), why is "a" such a problem child?

now in the latest insider update... gitgraph is totally destructed!

edit: WAS FIXED AFTER THE LATEST INSIDER

so, I've seen similar in Pwsh sessions on Windows, Windows to WSL, and now seeing on macOS with Pwsh core session. Never see this outside of VS Code's Terminal. similar here: https://github.com/microsoft/vscode/issues/120352#issue-848559087

I'm seeing this in a pwsh terminal (not the integreated terminal of the extension) in VS Code in a local session (not SSH):

@DLPVM2-VBOS-X86 ~/src/vscode-powershell andschwa/fix-release-build ≡
> ;1R;3R;13R;17R;18R;1R;1R;3R;6R;11R;17R1;1R2;3R2;17R2;15R6;1R7;3R7;10R7;12R7;13R7;22R9;1R0;3R0;8R0;10R0;16R0;18R0;23R0;25R0;31R0;49R1;1R1;3R1;8R1;16R1;31R1;3R1;5R1;9R1;24R1;37R1;1R1;3R1;1R1;3R1;5R1;11R1;10R1;13R1;13R1;14R1;26R1;29R1;40R1;41R1;47R1;1R1;3R1;5R1;1R1;3R1;9R1;1R1;3R1;1R1;3R1;8R1;14R1;1R1;3R1;1R1;3R1;9R1;1R1;3R1;1R1;3R1;17R1;1R1;3R1;6R1;13R1;21R1;29R1;1R1;3R1;4R1;3R1;3R1;12R1;16R1;17R1;13R1;1R1;3R1;7R1;13R1;12R1;16R1;19R1;27R1;42R1;1R1;3R1;6R1;9R1;12R1;19R1;23R1;35R1;38R1;53R1;53R1;55R1;53R1;53R1;54R1;56R1;151R1;151R1;151R1;151R1;151R1;151R1;151R1;151R1;3R1;53R1;54R1;55R1;55R1;148R1;148R1;3R1;55R1;56R1;56R1;28R1;3R1;57R1;58R1;60R1;62R1;64R1;68R1;69R1;73R1;80R1;1R0;1R1;3R1;1R1;3R1;1R1;3R1;7R1;6R1;80R1;3R1;9R1;1R1;3R1;5R1;6R1;5R1;8R1;9R1;10R1;10R1;13R1;22R1;3R1;4R1;17R1;19R1;35R1;36R1;35R1;1R1;3R1;3R1;8R1;12R1;21R1;1R1;3R1;8R1;1R1;3R1;7R1;10R1;11R1;11R1;14R1;15R1;16R1;28R1;42R1;49R1;1R1;3R1;1R1;3R1;7R

@TylerLeonhardt any change to VS Code? This just started happening with 1.55.1 for me.

It was after I reloaded the editor because I'd uninstalled an extension (specifically the PowerShell extension, so this is not an issue with the extension itself).

Thanks to @Tyriar there is a workaround https://github.com/microsoft/vscode/issues/120352#issuecomment-817816959 while this bug is being investigated:

"terminal.integrated.localEchoLatencyThreshold": -1

This has been mostly resolved upstream, marking as resolved here. You'll probably need to continue to use the posted workaround until VS Code updates make it your way.

Was this page helpful?
0 / 5 - 0 ratings