"Session using SocketStream throws ENOENT" test fails with libuv 1.20.3 #34
Comments
Maybe it changed to EINVAL? (libuv/libuv@239ab6b, JuliaLang/julia#26685 ) Though it's weird that the test claims no error was received. |
That change was Windows specific and isn't in the 1.x branch. |
Yeah, but I saw similar changes which suggested that this was a direction they were pursuing. Though it would be a breaking API change so it makes sense that it's not in 1.x. |
libuv/libuv#1741 (specifically libuv/libuv@8f9ba2a) is the most recent commit that causes the test to fail. The commit was present before (and reverted). I'll see if I can get any more information on why we're not getting an error back, as a simple C file appears to work fine. It looks like something specific to the lua layers. |
Adding some debug "printf"s, this is the difference in behavior:
|
Ok, so the problem is that We were only getting diff --git i/nvim/socket_stream.lua w/nvim/socket_stream.lua
index 37465b8..8dfbd53 100644
--- i/nvim/socket_stream.lua
+++ w/nvim/socket_stream.lua
@@ -16,6 +16,9 @@ function SocketStream.open(file)
end
function SocketStream:write(data)
+ if self._stream_error then
+ error(self._stream_error)
+ end
uv.write(self._socket, data, function(err)
if err then
error(self._stream_error or err)
@@ -24,6 +27,9 @@ function SocketStream:write(data)
end
function SocketStream:read_start(cb)
+ if self._stream_error then
+ error(self._stream_error)
+ end
uv.read_start(self._socket, function(err, chunk)
if err then
error(err)
@@ -33,6 +39,9 @@ function SocketStream:read_start(cb)
end
function SocketStream:read_stop()
+ if self._stream_error then
+ error(self._stream_error)
+ end
uv.read_stop(self._socket)
end
diff --git i/nvim/tcp_stream.lua w/nvim/tcp_stream.lua
index 4d79cf2..4e590e4 100644
--- i/nvim/tcp_stream.lua
+++ w/nvim/tcp_stream.lua
@@ -16,6 +16,9 @@ function TcpStream.open(host, port)
end
function TcpStream:write(data)
+ if self._stream_error then
+ error(self._stream_error)
+ end
uv.write(self._socket, data, function(err)
if err then
error(self._stream_error or err)
@@ -24,6 +27,9 @@ function TcpStream:write(data)
end
function TcpStream:read_start(cb)
+ if self._stream_error then
+ error(self._stream_error)
+ end
uv.read_start(self._socket, function(err, chunk)
if err then
error(err)
@@ -33,6 +39,9 @@ function TcpStream:read_start(cb)
end
function TcpStream:read_stop()
+ if self._stream_error then
+ error(self._stream_error)
+ end
uv.read_stop(self._socket)
end
The above diff fixes the issue, and passes the tests with both the old and new libuv. I also think it cleans up the interface a little bit since existing errors on the stream are directly propagated (before performing a subsequent action) rather than relying on something else to fail. Ideally we could |
During the setup of a Tcp/SocketStream, an error may occur which results in self._stream_error being set. libuv used to attempt to writing to the stream, regardless if the stream was considered writable. libuv/libuv@fd049399 (landed in 1.19.0, reverted in 1.19.1, and re-landed in 1.23.0) changed uv_write to consider the writable status of the stream. This broke lua-client's detection of the stream open failure, since we were only handling it when a write failure occurred. Rather than relying on a specific stream method to fail, all stream methods now check for self._stream_error and raise the error if it's set. This fixes the behavior with libuv versions that contain the writable check, while the write method's error callback maintains the behavior for other libuv versions. Closes neovim#34
During the setup of a Tcp/SocketStream, an error may occur which results in self._stream_error being set. libuv used to attempt to writing to the stream, regardless if the stream was considered writable. libuv/libuv@fd049399 (landed in 1.19.0, reverted in 1.19.1, and re-landed in 1.23.0) changed uv_write to consider the writable status of the stream. This broke lua-client's detection of the stream open failure, since we were only handling it when a write failure occurred. Rather than relying on a specific stream method to fail, all stream methods now check for self._stream_error and raise the error if it's set. This fixes the behavior with libuv versions that contain the writable check, while the write method's error callback maintains the behavior for other libuv versions. Closes #34
Debian's CI infrastructured discovered that this test started failing when libuv was upgraded to 1.20.3 (from 1.18.0):
While this is clearly a behavior change, I'm not sure if it's a regression in libuv or if we were relying on something that we shouldn't have been.
Any insight would be helpful to get this resolved.
I have limited time for the next ~week. I was going to try bisecting libuv, but between the annoying lua-client build (when you don't want bundled deps) and the fact that libuv is pulled in through lua-luv, I won't have time to do that soon.
The text was updated successfully, but these errors were encountered: