From 7729b4ae5a3f2f13cfdc2f8580de865b337f7529 Mon Sep 17 00:00:00 2001 From: Riz Ashraf Date: Wed, 23 Sep 2026 04:08:33 +0100 Subject: [PATCH] fix(nvim): resolve idle zombie connection lock and adjust RPC timeout - Remove the arbitrary 60-second read timeout on the Neovim socket that caused the read task to exit during idle periods, permanently locking the connection state. - Automatically clear the connection state variable when the read loop breaks (e.g. true EOF), allowing get_nvim_connection() to correctly auto-reconnect on the next call. - Increase the Neovim RPC call timeout from 10s to 30s to accommodate heavier operations (e.g., massive Lua regex substitutions) without falsely dropping the connection. --- nvim-core/src/lib.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/nvim-core/src/lib.rs b/nvim-core/src/lib.rs index 61df4bc..17189a1 100644 --- a/nvim-core/src/lib.rs +++ b/nvim-core/src/lib.rs @@ -254,16 +254,13 @@ async fn get_nvim_connection() -> Result, String> { } _ => false, } => - { - match tokio::time::timeout( - tokio::time::Duration::from_secs(60), - read_half.read_buf(&mut resp_buf), - ) - .await - { - Ok(Ok(n)) if n > 0 => {} + match read_half.read_buf(&mut resp_buf).await { + Ok(n) if n > 0 => {} _ => { - tracing::error!("Neovim socket read loop closed or timeout"); + tracing::error!("Neovim socket read loop closed or EOF"); + // We need to clear the connection state so the next call reconnects + let mut conn = NVIM_CONN.lock().unwrap_or_else(|e| e.into_inner()); + *conn = None; break; } } @@ -372,7 +369,7 @@ async fn call_nvim(req: rmpv::Value) -> Result { .await .map_err(|_| "Failed to send request to Neovim connection manager")?; - match tokio::time::timeout(tokio::time::Duration::from_secs(10), reply_rx).await { + match tokio::time::timeout(tokio::time::Duration::from_secs(30), reply_rx).await { Ok(Ok(res)) => res, Ok(Err(_)) => Err("Response channel dropped".to_string()), Err(_) => Err("Timeout waiting for Neovim response".to_string()),