Skip to content

Commit

Permalink
fix: EOF error on piped stderr being closed on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wookayin committed Oct 15, 2023
1 parent fd4247c commit 6ab90aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pynvim/msgpack_rpc/event_loop/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ def data_received(self, data: bytes) -> None:

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

def pipe_data_received(self, fd, data):
"""Used to signal `asyncio.SubprocessProtocol` of incoming data."""
if fd == 2: # stderr fd number
self._on_stderr(data)
# Ignore stderr message, log only for debugging
debug("stderr: %s", str(data))
elif self._on_data:
self._on_data(data)
else:
Expand Down

0 comments on commit 6ab90aa

Please sign in to comment.