{"record":{"id":"d72b907c15312742","repo":"sinelaw/fresh","slug":"cannot-open-file-remote-connection-lost","errorCode":null,"errorMessage":"Cannot open file: remote connection lost ({})","messagePattern":"Cannot open file: remote connection lost \\((.+?)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/fresh-editor/src/app/file_open_orchestrators.rs","lineNumber":1066,"sourceCode":"        // Notify LSP about the newly opened file (skip for binary files)\n        if !is_binary {\n            self.notify_lsp_file_opened(path, buffer_id, &mut metadata);\n        }\n\n        // Store metadata for this buffer\n        self.buffer_metadata.insert(buffer_id, metadata);\n    }\n\n    fn open_file_no_focus_inner(\n        &mut self,\n        path: &Path,\n        allow_replace_empty: bool,\n        kind: OpenKind,\n    ) -> anyhow::Result<BufferId> {\n        // Fail fast if the remote connection is down — don't attempt I/O that\n        // would either timeout or return confusing errors.\n        if !self.authority().filesystem.is_remote_connected() {\n            anyhow::bail!(\n                \"Cannot open file: remote connection lost ({})\",\n                self.authority()\n                    .filesystem\n                    .remote_connection_info()\n                    .unwrap_or(\"unknown host\")\n            );\n        }\n\n        // Resolve relative paths against appropriate base directory.\n        // For remote mode, use the remote home directory; for local, use\n        // this window's root.\n        let base_dir = if self\n            .authority()\n            .filesystem\n            .remote_connection_info()\n            .is_some()\n        {\n            self.authority()","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/app/file_open_orchestrators.rs#L1048-L1084","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\neditor.open_file_no_focus(path)?;\n// after\nif editor.filesystem().is_remote_connected() {\n    editor.open_file_no_focus(path)?;\n} else {\n    editor.reconnect_remote()?;\n    editor.open_file_no_focus(path)?;\n}","handlingStrategy":"retry","validationCode":"if !editor.filesystem().is_remote_connected() { editor.reconnect_remote()?; }","typeGuard":null,"tryCatchPattern":"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) }","preventionTips":["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"],"tags":["remote","network","file-open"],"backgroundTag":"connection-refused","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}