Skip to content

Commit 80bfc41

Browse files
committed
fix: EOF error on piped stderr being closed on Windows
Problem: An EOF error happens when creating a subprocess Nvim instance on Windows. All CI tests are failing, and `attach('child', ...)` cannot be run. Solution: Ignore pipe_connection_lost error, and do not close the asyncio event loop. Since embedded nvim only expects to use stdin and stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes on the stderr. Fixes #505
1 parent 1b1d6cd commit 80bfc41

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pynvim/msgpack_rpc/event_loop/asyncio.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ def data_received(self, data: bytes) -> None:
5959

6060
def pipe_connection_lost(self, fd, exc):
6161
"""Used to signal `asyncio.SubprocessProtocol` of a lost connection."""
62+
debug("pipe_connection_lost: fd = %s, exc = %s", fd, exc)
63+
if os.name == 'nt' and fd == 2: # stderr
64+
# On windows, ignore piped stderr being closed immediately (#505)
65+
return
6266
self._on_error(exc.args[0] if exc else 'EOF')
6367

6468
def pipe_data_received(self, fd, data):
6569
"""Used to signal `asyncio.SubprocessProtocol` of incoming data."""
6670
if fd == 2: # stderr fd number
67-
self._on_stderr(data)
71+
# Ignore stderr message, log only for debugging
72+
debug("stderr: %s", str(data))
6873
elif self._on_data:
6974
self._on_data(data)
7075
else:

0 commit comments

Comments
 (0)