sinelaw/fresh · critical
Cannot save: remote connection lost
Error message
Cannot save: remote connection lost ({}) What it means
save fails fast when the remote filesystem connection is down, before attempting to write the buffer, because the write would either time out or produce a confusing I/O error. The host info is included when known.
Solutions
- Reconnect the remote session, then retry the save.
- Before saving (especially on close), check is_remote_connected() and warn the user so edits aren't lost.
- Offer a local fallback save (e.g. write to a temp file) when the remote is unreachable.
Example fix
// before
if editor.buffer_is_modified(id) { editor.save()?; } // may bail on disconnect
// after
if editor.buffer_is_modified(id) {
if !editor.filesystem().is_remote_connected() { editor.reconnect_remote()?; }
editor.save()?;
} Defensive patterns
Strategy: validation
Validate before calling
if !editor.filesystem().is_remote_connected() { editor.reconnect_remote()?; } // then save Try / catch
match editor.save() { Err(e) if e.to_string().starts_with("Cannot save: remote connection lost") => { backup_to_local_tmp(buffer); notify_user(); } r => r } Prevention
- Check connection state before save, especially on buffer close
- Keep a local emergency copy of dirty remote buffers
- Monitor remote health and reconnect proactively
When it happens
Trigger: Calling Editor::save (from handle_action, handle_prompt_confirm_input, or handle_confirm_close_buffer) while authority().filesystem.is_remote_connected() is false.
Common situations: Pressing Ctrl+S after an SSH drop; closing a buffer with a pending save prompt during a network outage; saving on laptop sleep/resume where the remote session died.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Cannot open file: remote connection lost
- ${built.error}
- No file path associated with buffer
- could not open from container
- Cannot open files from multiple remote hosts. First
AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13).
Data as JSON: /api/errors/29638acb26e6fe0e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor/src/app/file_operations.rs:50
.iter()
.filter(|(_, state)| {
state.buffer.is_modified()
&& state
.buffer
.file_path()
.map(|p| p.as_os_str().is_empty())
.unwrap_or(true)
})
.map(|(id, _)| *id)
.collect()
}
impl Editor {
/// Save the active buffer
pub fn save(&mut self) -> anyhow::Result<()> {
// Fail fast if remote connection is down
if !self.authority().filesystem.is_remote_connected() {
anyhow::bail!(
"Cannot save: remote connection lost ({})",
self.authority()
.filesystem
.remote_connection_info()
.unwrap_or("unknown host")
);
}
let path = self
.active_state()
.buffer
.file_path()
.map(|p| p.to_path_buf());
match self.active_state_mut().buffer.save() {
Ok(()) => self.finalize_save(path),
Err(e) => {
if let Some(sudo_info) = e.downcast_ref::<SudoSaveRequired>() {View on GitHub (pinned to 67894ca546)