Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Debugging with shortly-lived subprocesses gives 'Server disconnected unexpectedly'

Open
#1,912 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
linux, python, vscode

Research direction

No source file or test is named. Start by reproducing the short-lived subprocess case from the issue with subProcess: true in launch.json on Windows 11 with Debian 12 under WSL2, then trace debugpy's subprocess attach and disconnect handling. Done means the reproducer exits without showing “Server disconnected unexpectedly” while normal debugger behavior remains intact.

Written by the indexing model from the issue text.

Description

needs repro

VSCode shows an error when a subprocess in a program under debug exits very fast and the subProcess: true is defined in launch.json.

Image

The problem disappears when subProcess: false is set.
Reproduced on two different machines (W11+WSL)

When running the debugger via Powershell on Windows the problem is not reproducible. Only W11+WSL.

Environment data

  • debugpy version: v2025.8.0
  • OS and version: Windows 11 + Debian GNU/Linux 12 (bookworm) (WSL2) [Remote host]
  • Python version: 3.11.2
  • Using VS Code: 1.101.0

Actual behavior

When debugging a python program that spawns a subprocess that exits too quickly this error is shown:

Image

It happens randomly and is possibly related to the subprocess exiting while the debugger is being attached.

Expected behavior

Error does not pop up and the debugger handles such case gracefully.

Steps to reproduce:

  1. Run code that spawns another python subprocess - for example with a module that doesn't exist
import subprocess

def main():
    cmd = "python3 -m idontexist"
    for i in range(0, 20):
        process = subprocess.Popen(cmd.split())
        process.wait()

if __name__ == "__main__":
    main()
Dominant language
Python
Stars
2.5k
Forks
202
Avg merge
5d 1h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/debugpy

All issues in microsoft/debugpy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.