microsoft / microsoft/vscode

VSCode server LEAKs server-main.js process.

Open
#332,764 1 comment 0 reactions 1 assignee Claimed by @connor4312 View on GitHub
bug
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

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

- VS Code Version: 1.135.0 (`08d4889f9ec4a1685d257b9b95de036c8e1ce1e5`, x64)
- OS Version: Linux in Docker, with Tini as PID 1

This leak has been observed for a long time across multiple VS Code versions and is still present after updating to 1.135.0.

Steps to Reproduce:

1. Start `code serve-web`, connect once, then disconnect all clients.
2. Wait for the one-hour idle timeout and connect again.

After reconnecting, the previous `server-main.js` remains alive under PID 1 while `serve-web` starts a new instance:

```text
tini
├── code serve-web
│ └── sh bin/code-server
│ └── node out/server-main.js # new
└── node out/server-main.js # old, PPID 1
```

Possibly relevant code: `serve-web` starts the server with `new_script_command()` and calls `child.kill()` when the idle timeout is reached:

https://github.com/microsoft/vscode/blob/08d4889f9ec4a1685d257b9b95de036c8e1ce1e5/cli/src/commands/serve_web.rs#L823-L833

https://github.com/microsoft/vscode/blob/08d4889f9ec4a1685d257b9b95de036c8e1ce1e5/cli/src/commands/serve_web.rs#L923-L928

For comparison, #319516 reported a similar leaked server process in the agent-host path, and #320631 changed that path to use `kill_tree()`:

https://github.com/microsoft/vscode/blob/08d4889f9ec4a1685d257b9b95de036c8e1ce1e5/cli/src/tunnels/agent_host.rs#L578-L590

Expected: the idle timeout should stop the server completely, without leaving an old `server-main.js` process under PID 1. Could the `serve-web` shutdown path be missing the process-tree handling added for the agent-host path?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.