sxyazi/yazi · error
Connection closed before receiving reply
Error message
Connection closed before receiving reply
What it means
`Dds::ask` loops reading reply lines and returns on the first matching custom reply; if the stream ends (EOF) before any matching reply arrives, it bails with `Connection closed before receiving reply`. This means the peer disconnected or never answered within the connection's lifetime.
Source
Thrown at yazi-cli/src/dds/exec.rs:69
drop(writer);
while let Ok(Some(line)) = lines.next_line().await {
match line.split(',').next() {
Some("hey") => {
if let Ok(Ember::Hey(hey)) = Payload::from_str(&line).map(|p| p.body) {
Self::ensure_version(Some(&hey.version))?;
Self::ensure_ability(&hey.peers, kind, receiver)?;
}
}
Some(kind) if kind == reply_kind => match Payload::from_str(&line)?.body {
Ember::Custom(body) => return Ok(body.data),
_ => bail!("Expected custom payload of kind `{reply_kind}`"),
},
_ => {}
}
}
bail!("Connection closed before receiving reply")
}
}
View on GitHub (pinned to 5f901b886b)
Solutions
- Verify Yazi is still running (`pgrep yazi`) and retry the command.
- Check Yazi logs (`YAZI_LOG=debug`) for a crash or handler panic around the request time.
- Confirm `YAZI_PID` points to a live instance, then re-run the `ya` command.
Defensive patterns
Strategy: retry
Validate before calling
if !yazi_running() { return Err("yazi is not running; start it before sending messages"); } Try / catch
match Dds::ask(...).await {
Err(e) if e.to_string() == "Connection closed before receiving reply" => {
if yazi_running() { retry_with_backoff(2) } else { eprintln!("yazi exited mid-request") }
}
other => other,
} Prevention
- Confirm the target yazi process is alive before long-running requests.
- Avoid restarting or killing yazi while `ya` requests are in flight.
- Check yazi logs for panics/crashes if disconnects recur.
When it happens
Trigger: Yazi exits or crashes while `ya` waits for the reply; the connection drops (network/IPC socket closed); the peer never emits the expected `reply_kind` line before closing.
Common situations: Target Yazi instance killed mid-request; long-running requests outliving a Yazi restart; `ya pub` sent to a receiver that shuts down before replying.
Understand the failure class
- Connection failures: ECONNREFUSED, ECONNRESET, and friends — why connections get refused, reset, or dropped.
Related errors
- {}
- Unknown error
- Expected custom payload of kind `{reply_kind}`
- Incompatible version (Ya {}, Yazi {}). Restart all `ya` and
- No receiver found. Check if any receivers are running.
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/713f9720f37ecd87.
Report an issue: GitHub.