Skip to content

vscode leaking tty fd's #182212

Closed
Closed

Description

@cpuguy83

Does this issue occur when all extensions are disabled?: TBD

  • VS Code Version:
Version: 1.78.1
Commit: 6a995c4f4cc2ced6e3237749973982e751cb0bf9
Date: 2023-05-04T10:01:22.349Z (1 wk ago)
Electron: 22.5.1
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.4.0
Sandboxed: No
  • OS Version:

macOS 13.3.1 (a) (22E772610a)

Steps to Reproduce:

I've had this happen twice now, once today and last time was on May 5th.
I try to connect to my remote session and I get this:

image

I try to jump into my macOS terminal, which I typically always have open anyway and run some commands, ssh works fine of course, perplexed... I wound up trying to open a new tab with a new terminal and it fails...
After much digging I find this:

% lsof | grep /dev/ptmx | grep Code | wc -l
     510

vscode is using all of my available TTY fd's.
This happened in the course of 2 days (I rebooted the machine 2 days ago).
It is worth noting right now I have 3 vscode windows open, all disconnected from the remote.
Closing all vscode windows (but with the vscode process still running as happens on macOS until you cmd+q it) does not change this number.
Actually quitting vscode gives me all my tty fd's back.

(let's assume from now on when I say fd I'm referring to /dev/ptmx fd's)

On a brand new vscode instance (no remote connection or anything), just a window open there are 0 open fd's from vscode.
Opening one terminal in vscode there are now 2 fd's opened.
After closing that terminal there is 1 fd open.
Opening a new terminal there are 3 fd's open.
Closing that terminal there are 2 fd's open now.
Open a new terminal and there are now 4 fd's (seeing a pattern here).
Opening a 2nd terminal there are 6 fd's open.
Close that 2nd terminal 5 fd's.
Connect to a remote, which automatically opens a new terminal, 8 fd's.
Close the remote terminal, still 8 fd's open.
Open a new remote terminal, still 8 fd's open (some re-use here?)
Open 3 more remote terminals, still 8 fd's open.
Go back to the original local window and open a remote project, 10 fd's open. (seems remote's share the same local fd's between terminals in one window)
Close that window, create a new window and open the same remote project, 13 fd's open.
Closing all open windows (but keeping vscode running) still 13 fd's open
Open a new window connected to the same remote+project, 16 fd's open.

Based on this pattern it looks like:

  • Local terminals leak 1 fd per terminal after closing
  • Remote terminals share the same 2 local fd's for all terminals in one window
  • New windows connected to the same remote get new fd's
  • fd's attached to remote terminals are never closed until vscode as a whole is closed.

Activity

  1. Tyriar commented on May 12, 2023

    @Tyriar
    Contributor

    Reported in the past here: #58814

    Robo (@deepak1556) + Raymond Zhao (@rzhao271) you might know how to fix this?

  2. cpuguy83 commented on May 12, 2023

    @cpuguy83
    Author

    I logged in this morning to find all my TTY fd's used up again.
    I definitely did not have anywhere close to that much churn yesterday, so it seems like there's something else at play in vscode.
    Maybe something related to disconnected remote sessions?

  3. deepak1556 commented on May 13, 2023

    @deepak1556
    Collaborator

    This might be a regression from microsoft/node-pty#589, will investigate.

  4. added
    bugIssue identified by VS Code Team member as probable bug
    upstreamIssue identified as 'upstream' component related (exists outside of VS Code)
    on May 13, 2023
  5. 18 remaining items

  6. RblSb commented on Dec 19, 2023

    @RblSb

    Still not fixed. Every build task run on macos allocates new virtual terminal, after day of build runs you will need to restart vscode. Very annoying.
    image

    Robo (@deepak1556) please, at least add regression tag and remove confirmation-pending if you can repro this:
    echo.zip

  7. added
    confirmedIssue has been confirmed by VS Code Team member
    and removed
    upstreamIssue identified as 'upstream' component related (exists outside of VS Code)
    on Jan 28, 2026
  8. added
    unreleasedPatch has not yet been released in VS Code Insiders
    insiders-releasedPatch has been released in VS Code Insiders
    and removed
    unreleasedPatch has not yet been released in VS Code Insiders
    on Jan 29, 2026
  9. deepak1556 commented on Jan 29, 2026

    @deepak1556
    Collaborator

    Steps for verification

    • Close any running instances of VS Code
    • Check the output of lsof | grep /dev/ptmx | grep Code | wc -l is 0
    • Open and launch a couple of integrated terminals
    • Check the output of lsof | grep /dev/ptmx | grep Code | wc -l and it should be non-zero
    • Close all integrated terminals
    • Check the output of lsof | grep /dev/ptmx | grep Code | wc -l is 0
  10. locked and limited conversation to collaborators on Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugconfirmedIssue has been confirmed by VS Code Team memberinsiders-releasedPatch has been released in VS Code InsidersmacosIssues with VS Code on MAC/OS Xterminal-processProblems launching processes, managing ptys, exiting, process leaks, etc.verifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions