Skip to content

Commit 0dd33dd

Browse files
committed
Fix #108: Debugger freezes in VSCode
When talking DAP over stdio, disable stderr before logging anything to it.
1 parent 2ff3c11 commit 0dd33dd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/debugpy/adapter/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121

2222
def main(args):
23+
# If we're talking DAP over stdio, stderr is not guaranteed to be read from,
24+
# so disable it to avoid the pipe filling and locking up. This must be done
25+
# as early as possible, before the logging module starts writing to it.
26+
if args.port is None:
27+
sys.stderr = open(os.devnull, "w")
28+
2329
from debugpy import adapter
2430
from debugpy.common import compat, log, sockets
2531
from debugpy.adapter import clients, servers, sessions

src/debugpy/adapter/clients.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def __init__(self, sock):
4343
# that are going to be used for DAP communication from now on.
4444
sys.stdin = open(os.devnull, "r")
4545
sys.stdout = open(os.devnull, "w")
46-
sys.stderr = open(os.devnull, "w")
4746
else:
4847
stream = messaging.JsonIOStream.from_socket(sock)
4948

0 commit comments

Comments
 (0)