Skip to content

Commit fdf8852

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 8e5dac6 commit fdf8852

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
@@ -60,12 +60,17 @@ def data_received(self, data: bytes) -> None:
6060

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

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

0 commit comments

Comments
 (0)