Debugging with shortly-lived subprocesses gives 'Server disconnected unexpectedly'
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
- Domain
- devtools, operating-systems
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
VSCode shows an error when a subprocess in a program under debug exits very fast and the subProcess: true is defined in launch.json.
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:
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:
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/debugpy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
All issues in microsoft/debugpy
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·