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.
This commit is contained in:
1 parent
ab1d209c1d
commit
7729b4ae5a
1 file changed
+7
-10
+7
-10
@@ -254,16 +254,13 @@ async fn get_nvim_connection() -> Result<mpsc::Sender<NvimRequest>, 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<rmpv::Value, String> {
|
||||
.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()),
|
||||
|
||||
Reference in new issue
Block a user