remote: Do not swallow ssh errors (#58780)
Release Notes: - Fixed non-descriptive error messages when remote agent processed disconnected
This commit is contained in:
1 parent
11d452f8d1
commit
9d76bd1265
6 files changed
+17
-30
No files matched your search
@@ -795,7 +795,7 @@ impl AcpConnection {
|
||||
project.remote_client().and_then(|client| {
|
||||
let template = client
|
||||
.read(cx)
|
||||
.build_command_with_options(
|
||||
.build_command(
|
||||
Some(command.path.display().to_string()),
|
||||
&command.args,
|
||||
&command.env.clone().into_iter().flatten().collect(),
|
||||
|
||||
@@ -20,7 +20,7 @@ use http_client::HttpClient;
|
||||
use itertools::Itertools;
|
||||
use rand::Rng as _;
|
||||
use registry::ContextServerDescriptorRegistry;
|
||||
use remote::RemoteClient;
|
||||
use remote::{Interactive, RemoteClient};
|
||||
use rpc::{AnyProtoClient, TypedEnvelope, proto};
|
||||
use settings::{Settings as _, SettingsStore};
|
||||
use util::{ResultExt as _, rel_path::RelPath};
|
||||
@@ -801,6 +801,7 @@ impl ContextServerStore {
|
||||
&response.env.into_iter().collect(),
|
||||
root_dir,
|
||||
None,
|
||||
Interactive::Yes,
|
||||
)
|
||||
})?;
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ impl DapStore {
|
||||
}
|
||||
|
||||
let command = remote.read_with(cx, |remote, _cx| {
|
||||
remote.build_command_with_options(
|
||||
remote.build_command(
|
||||
binary.command,
|
||||
&binary.arguments,
|
||||
&binary.envs,
|
||||
|
||||
@@ -6,7 +6,7 @@ use async_channel::bounded;
|
||||
use futures::{FutureExt, future::Shared};
|
||||
use itertools::Itertools as _;
|
||||
use language::LanguageName;
|
||||
use remote::RemoteClient;
|
||||
use remote::{Interactive, RemoteClient};
|
||||
use settings::{Settings, SettingsLocation};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
@@ -558,6 +558,7 @@ impl Project {
|
||||
&env,
|
||||
None,
|
||||
None,
|
||||
Interactive::Yes,
|
||||
)?;
|
||||
let mut command = new_std_command(command_template.program);
|
||||
command.args(command_template.args);
|
||||
@@ -631,6 +632,7 @@ fn create_remote_shell(
|
||||
&env,
|
||||
working_directory.map(|path| path.display().to_string()),
|
||||
None,
|
||||
Interactive::Yes,
|
||||
)?;
|
||||
|
||||
log::debug!("Connecting to a remote server: {:?}", command.program);
|
||||
|
||||
@@ -930,24 +930,6 @@ impl RemoteClient {
|
||||
env: &HashMap<String, String>,
|
||||
working_dir: Option<String>,
|
||||
port_forward: Option<(u16, String, u16)>,
|
||||
) -> Result<CommandTemplate> {
|
||||
self.build_command_with_options(
|
||||
program,
|
||||
args,
|
||||
env,
|
||||
working_dir,
|
||||
port_forward,
|
||||
Interactive::Yes,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build_command_with_options(
|
||||
&self,
|
||||
program: Option<String>,
|
||||
args: &[String],
|
||||
env: &HashMap<String, String>,
|
||||
working_dir: Option<String>,
|
||||
port_forward: Option<(u16, String, u16)>,
|
||||
interactive: Interactive,
|
||||
) -> Result<CommandTemplate> {
|
||||
let Some(connection) = self.remote_connection() else {
|
||||
|
||||
@@ -1863,9 +1863,9 @@ fn build_command_posix(
|
||||
));
|
||||
}
|
||||
|
||||
// -q suppresses the "Connection to ... closed." message that SSH prints when
|
||||
// the connection terminates with -t (pseudo-terminal allocation)
|
||||
args.push("-q".into());
|
||||
// LogLevel=ERROR suppresses the "Connection to ... closed." message while
|
||||
// preserving SSH errors.
|
||||
args.extend(["-o".into(), "LogLevel=ERROR".into()]);
|
||||
match interactive {
|
||||
// -t forces pseudo-TTY allocation (for interactive use)
|
||||
Interactive::Yes => args.push("-t".into()),
|
||||
@@ -1958,9 +1958,9 @@ fn build_command_windows(
|
||||
));
|
||||
}
|
||||
|
||||
// -q suppresses the "Connection to ... closed." message that SSH prints when
|
||||
// the connection terminates with -t (pseudo-terminal allocation)
|
||||
args.push("-q".into());
|
||||
// LogLevel=ERROR suppresses the "Connection to ... closed." message while
|
||||
// preserving SSH errors.
|
||||
args.extend(["-o".into(), "LogLevel=ERROR".into()]);
|
||||
match interactive {
|
||||
// -t forces pseudo-TTY allocation (for interactive use)
|
||||
Interactive::Yes => args.push("-t".into()),
|
||||
@@ -2039,7 +2039,8 @@ mod tests {
|
||||
[
|
||||
"-p",
|
||||
"2222",
|
||||
"-q",
|
||||
"-o",
|
||||
"LogLevel=ERROR",
|
||||
"-t",
|
||||
"user@host",
|
||||
"cd \"$HOME\"/work && exec env 'INPUT_VA=val' remote_program arg1 arg2"
|
||||
@@ -2075,7 +2076,8 @@ mod tests {
|
||||
"2222",
|
||||
"-L",
|
||||
"1:foo:2",
|
||||
"-q",
|
||||
"-o",
|
||||
"LogLevel=ERROR",
|
||||
"-t",
|
||||
"user@host",
|
||||
"cd && exec env 'INPUT_VA=val' /bin/fish -l"
|
||||
|
||||
Reference in new issue
Block a user