From eb2e695e40a547d29d0bba3416f59d4ad1f64dbc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 11 Jul 2026 06:52:04 -0400 Subject: [PATCH] test: "Failed to start server: address already in use" #40683 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: unreliable test: FAILED …/tui_spec.lua @ 895: TUI mouse events work with right-click menu (escape sequences sent to child) D:/a/…/testnvim.lua:144: Vim:Failed to start server: address already in use stack traceback: D:/a/…/testnvim.lua:144: in function 'eval' D:/a/…/testnvim.lua:1015: in function 'new_pipename' …/tui_spec.lua:897: in function <…/tui_spec.lua:895> Solution: Workaround potential PID reuse. --- test/functional/testnvim.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua index 9e676edab2..7d20281852 100644 --- a/test/functional/testnvim.lua +++ b/test/functional/testnvim.lua @@ -1012,7 +1012,20 @@ end --- @return string function M.new_pipename() -- HACK: Start a server temporarily, get the name, then stop it. - local pipename = M.eval('serverstart()') + -- + -- XXX: If a (still-alive) Nvim process is using an old "--listen nvim.." pipename, + -- and the OS reuses the PID, then serverstart() may generate a duplicate name (bc of PID reuse). + -- Retry serverstart() to force an incremented . + local ok = false + local pipename ---@type string + for _ = 1, 100 do + ok, pipename = pcall(M.eval, 'serverstart()') + if ok then + break + end + sleep(20) -- Avoid hot loop; give stale process time to exit. + end + assert(ok, pipename) M.fn.serverstop(pipename) -- Remove the pipe so that trying to connect to it without a server listening -- will be an error instead of a hang.