Skip to content

Console host / terminal tab will not exit after using code to open the first Code window, until all Code windows are closed #264183

@GeeLaw

Description

@GeeLaw

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

  • VS Code Version: 1.103.2, 6f17636121051a53c88d3e605c491d22af2ba755, x64
  • OS Version: Windows 11 version 24H2 build 26100.3775 x64

Steps to Reproduce:

  1. Close all existing Code windows and all existing PowerShell instances.
  2. Start PowerShell, run code; exit.
  3. Observe that the PowerShell console or the PowerShell terminal tab hangs.
  4. Open Task Manager and look for PowerShell process. Observe that PowerShell has exited.
  5. Close the Code window normally (not using Task Manager). Observe that the PowerShell console or the PowerShell terminal tab exits once the Code window is closed.

Expected behavior: Step 3, the console or the terminal tab should exit.

Steps to Reproduce (continued):

  1. Close all existing Code windows and all existing PowerShell instances.
  2. Start PowerShell, run code, then close the console or the terminal tab using the X button.
  3. Start PowerShell again, run code; exit.
  4. Observe that the second console or the second terminal tab exits normally.

There are other things to try, such as using code path-to-dir or code path-to-file. A simple description consistent with what I observe in all those trials:

  • If the code command opens a new window (file or directory or just running code), then it will block the console host or the terminal from shutting down, until the newly opened window is closed.
  • If the code command did not open a new window, then it will not block the console host or the terminal from shutting down.

Psychic debugging:

  • The code command starts Code.exe (for cli.js). Let's call the started process Code[1]. It is monitored by the terminal tab.
  • If Code[1] determines a new window is not needed, it communicates the action to an existing window, and Code[1] terminates (unless --wait is specified). This means if the code command did not open a new window, then it will not block tab close.
  • If Code[1] determines a new window is needed, it will launch some other Code.exe instances. For reason unknown to me, one of them (I suspect Code[1] does, also it seems to be the one hosting GUI) causes the terminal tab to wait upon closing.

Normally, a GUI-subsystem program should be detached from the console. For example, running Notepad.exe then running exit, then tab closes normally. For unknown reason, Code.exe (and possibly, all Electron-based programs) did not break away from the console?

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions