Skip to content

Commit bc54e4b

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 e4f6181 commit bc54e4b

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

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

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

0 commit comments

Comments
 (0)