Describe the bug
When the remote Neovim server starts up and becomes ready before the 20-second timeout fires, both the readiness probe (probe_server_readiness) and the timeout callback in _wait_for_server_to_be_ready can reach timer:close(). libuv raises an error on the second call because the handle is already closing.
To reproduce
- Run
nvim -u repro.lua
- Connect to any remote host via SSH
- Wait for the session to launch. The error appears in the progress view once the server is ready
Expected behavior
No error. If the timer is already closing, the second close() call should be a no-op.
Screenshot/Screencast(s)
Error executing vim.schedule lua callback: .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:813: handle 0x55f8ae22c410 is already
closing
stack traceback:
[C]: in function 'close'
.../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:813: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
System information
- Local OS: Linux (CachyOS) 6.19.3-2-cachyos x86_64
- Local Neovim version: v0.11.6
- Remote host OS: Arch Linux 6.18.9-arch1-2 x86_64
- Remote Neovim version: v0.11.6
Additional context
The race condition is in provider.lua around lines 808–831. Both the success path and the timeout path call timer:stop() + timer:close() with no guard. The fix is a one-liner:
-- line ~812 (success path)
if not timer:is_closing() then
timer:stop()
timer:close()
end
-- line ~828 (timeout path)
if not timer:is_closing() then
timer:stop()
timer:close()
end
Describe the bug
When the remote Neovim server starts up and becomes ready before the 20-second timeout fires, both the readiness probe (probe_server_readiness) and the timeout callback
in _wait_for_server_to_be_readycan reachtimer:close(). libuvraises an error on the second call because the handle is already closing.To reproduce
nvim -u repro.luaExpected behavior
No error. If the timer is already closing, the second close() call should be a no-op.
Screenshot/Screencast(s)
Error executing vim.schedule lua callback: .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:813: handle 0x55f8ae22c410 is already closing stack traceback: [C]: in function 'close' .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:813: in function '' vim/_editor.lua: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>System information
Additional context
The race condition is in
provider.luaaround lines 808–831. Both the success path and the timeout path calltimer:stop() + timer:close()with no guard. The fix is a one-liner: