sinelaw/fresh · critical
Cannot open file: remote connection lost
Error message
Cannot open file: remote connection lost ({}) What it means
open_file_no_focus_inner checks the remote filesystem connection up front and bails if it is disconnected, avoiding I/O calls that would hang or produce confusing errors. The message includes the remote host info when available.
Solutions
- Reconnect the remote filesystem/session before retrying the open.
- Check connection state with is_remote_connected()/remote_connection_info() before issuing file operations.
- Retry the open after the network is restored; add automatic reconnect logic to the remote authority.
Example fix
// before
editor.open_file_no_focus(path)?;
// after
if editor.filesystem().is_remote_connected() {
editor.open_file_no_focus(path)?;
} else {
editor.reconnect_remote()?;
editor.open_file_no_focus(path)?;
} Defensive patterns
Strategy: retry
Validate before calling
if !editor.filesystem().is_remote_connected() { editor.reconnect_remote()?; } Try / catch
match open_res { Err(e) if e.to_string().starts_with("Cannot open file: remote connection lost") => reconnect_and_retry(), Err(e) => return Err(e), Ok(id) => Ok(id) } Prevention
- Gate all remote file operations behind an is_remote_connected() check
- Implement automatic reconnect with backoff on the remote authority
- Surface connection state in the UI so users notice before operating
When it happens
Trigger: Any open path (open_file_no_focus, open_file_no_focus_with_kind, open_file_for_preview) when authority().filesystem.is_remote_connected() returns false — SSH/remote session dropped before the open attempt.
Common situations: Network drop or SSH disconnect during an editing session; remote host rebooted; trying to open a file after the remote session was closed but the editor is still running.
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
- could not open from container
- Cannot save: remote connection lost
- ${built.error}
- Cannot open files from multiple remote hosts. First
- Cannot mix local and remote files. Use either local paths…
AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13).
Data as JSON: /api/errors/d72b907c15312742.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor/src/app/file_open_orchestrators.rs:1066
// Notify LSP about the newly opened file (skip for binary files)
if !is_binary {
self.notify_lsp_file_opened(path, buffer_id, &mut metadata);
}
// Store metadata for this buffer
self.buffer_metadata.insert(buffer_id, metadata);
}
fn open_file_no_focus_inner(
&mut self,
path: &Path,
allow_replace_empty: bool,
kind: OpenKind,
) -> anyhow::Result<BufferId> {
// Fail fast if the remote connection is down — don't attempt I/O that
// would either timeout or return confusing errors.
if !self.authority().filesystem.is_remote_connected() {
anyhow::bail!(
"Cannot open file: remote connection lost ({})",
self.authority()
.filesystem
.remote_connection_info()
.unwrap_or("unknown host")
);
}
// Resolve relative paths against appropriate base directory.
// For remote mode, use the remote home directory; for local, use
// this window's root.
let base_dir = if self
.authority()
.filesystem
.remote_connection_info()
.is_some()
{
self.authority()View on GitHub (pinned to 67894ca546)