Repository: vscode
Issue: Persistent error : Could not find pty on pty host
Labels: bug,remote,confirmation-pending,terminal-process

VSCode over Windows 10, with Remote SSH extension to a remote Ubuntu v20. I've been running this configuration for many months. Remote extensions are acting a bit wonky. I can't tell if this is a recent issue, after an update, or within the last couple months. I'm just trying now to get extensions to work while installed remotely, and they are not, so I'm investigating causes.

While trying to diagnose that I found that on the every initial SSH connection that the Output : Window reports:

> [error] Could not find pty on pty host: CodeExpectedError: Could not find pty on pty host

<details>
<summary>Detail from Output : Window</summary>

```log
2024-04-19 13:03:03.059 [info] [LocalProcess0][resolveAuthority(ssh-remote,1)][26305ms] waiting...
2024-04-19 13:03:04.066 [info] [LocalProcess0][resolveAuthority(ssh-remote,1)][27313ms] waiting...
2024-04-19 13:03:05.004 [info] [LocalProcess0][resolveAuthority(ssh-remote,1)][28250ms] returned Managed(1)
2024-04-19 13:03:05.004 [info] resolveAuthority(ssh-remote) returned 'Managed(1)' after 28252 ms
2024-04-19 13:03:05.030 [info] Creating a socket (renderer-Management-855038fc-c9f5-4b79-a305-73937542dd9a)...
2024-04-19 13:03:05.031 [info] Creating a socket (renderer-ExtensionHost-a739e94d-7d7f-402e-89d0-a31fdb2f8598)...
2024-04-19 13:03:05.197 [info] Creating a socket (renderer-ExtensionHost-a739e94d-7d7f-402e-89d0-a31fdb2f8598) was successful after 169 ms.
2024-04-19 13:03:05.199 [info] Creating a socket (renderer-Management-855038fc-c9f5-4b79-a305-73937542dd9a) was successful after 172 ms.
2024-04-19 13:03:07.121 [info] [perf] Render performance baseline is 32ms
2024-04-19 13:03:07.681 [error] Could not find pty on pty host: CodeExpectedError: Could not find pty on pty host
    at D.U (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:47:32471)
    at D.updateTitle (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:47:27632)
    at j.<computed> (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:47:22875)
    at Object.call (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:36:5137)
    at l.s (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:34:5145)
    at l.q (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:34:4647)
    at n.value (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:34:4045)
    at t.y (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:29:665)
    at t.fire (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:29:882)
    at process.ue (/home/ubuntu/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/out/vs/platform/terminal/node/ptyHostMain.js:25:10030)
    at process.emit (node:events:517:28)
    at emit (node:internal/child_process:944:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
2024-04-19 13:03:32.240 [info] Extension host (Remote) is unresponsive.
2024-04-19 13:03:35.973 [info] Extension host (Remote) is responsive.
```

</details>

I believe this is the correct stack leading to that : [ptyHostMain](https://github.com/microsoft/vscode/blob/f86134162494bb2ff6dc3cfc849f5d3b7e056819/src/vs/platform/terminal/node/ptyHostMain.ts#L83) > [ptyService](https://github.com/microsoft/vscode/blob/f86134162494bb2ff6dc3cfc849f5d3b7e056819/src/vs/platform/terminal/node/ptyService.ts#L311) > [throw](https://github.com/microsoft/vscode/blob/f86134162494bb2ff6dc3cfc849f5d3b7e056819/src/vs/platform/terminal/node/ptyService.ts#L603)

I have been running the Release version of the Remote SSH extension but loaded the Pre-Release today to see if the issue was fixed. Nope.

It may or may not be related but I'm also struggling with SSH connection drops. The session will be fine for a long time, until "something changes" and then it goes into a reconnect state and cannot reconnect. I need to restart the connection. This also happens with no other extensions. I have other SSH sessions open to the same server:port/user and there are no drops. To my knowledge, only VSCode is experiencing issues.

The issues with extensions may or may not be related. My focus right now is only on this error from ptyHostMain. When this is resolved I'll move up the chain for the other challenges.

I do not see related issues noted in server logs but will activate and check debug logs if details are provided here.

The .vscode-server folder has been deleted and recreated many times. After closing the client-side app I've terminated the server pids.

Used/Max Ptys = 1/4096

Other settings from VSCode:

```json
// user
  "remote.SSH.connectTimeout": 120,
  "remote.SSH.enableRemoteCommand": true,
  "remote.SSH.enableX11Forwarding": false,
  "remote.SSH.localServerDownload": "auto",
  "remote.SSH.logLevel": "debug",
  "remote.SSH.showLoginTerminal": true,
// app
  "remote.SSH.useLocalServer": false, // was true, no difference
  "remote.SSH.connectTimeout": 120
```

```
# vscode_remote.config
  PreferredAuthentications publickey
  ServerAliveInterval 60
  ServerAliveCountMax 10
```

I researched this issue in Issues here, in StackOverflow, and with other googling, but found nothing close to this previously reported.

Dunno what else I can add. I have full access to client and server and will be eager to provide info, and load and test patches.

Thanks.

(I tried to post this from in-app Issue Reporter and the "Create on GitHub" button wasn't responsive. ( #134530 )


<details>
<summary>System Info</summary>

Version: 1.88.1 (system setup)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39 ( client and server agree )
Date: 2024-04-10T17:41:02.734Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2 (default server version is v20 but I believe VSC uses 18)
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.19045



CPUs | Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz (16 x 2304)
-- | --
GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled
Load (avg) |  
Memory (System) | 31.82GB (15.59GB free)
Process Argv | --crash-reporter-id 3555131d-7d56-4887-a807-ceafc2556f0b
Screen Reader | no
VM | 0%


Extension | Author (truncated) | Version
-- | -- | --
remote-ssh | ms- | 0.111.2024040515
remote-ssh-edit | ms- | 0.86.0
remote-explorer | ms- | 0.4.3


</details>