Skip to content

Commit

Permalink
ENG-2768 Print an error message if SSH fails to establish a connection (
Browse files Browse the repository at this point in the history
#127)

Prints an error message if SSH fails to establish a connection.
  • Loading branch information
fabgo authored Oct 3, 2024
1 parent ef94232 commit f3f18bf
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/plugins/ssh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ type SpawnSshNodeOptions = {
isAccessPropagationPreTest?: boolean;
};

/** Starts an SSM session in the terminal by spawning `aws ssm` as a subprocess
*
* Requires `aws ssm` to be installed on the client machine.
*/

async function spawnSshNode(
options: SpawnSshNodeOptions
): Promise<number | null> {
Expand Down Expand Up @@ -183,7 +178,15 @@ async function spawnSshNode(
}

options.abortController?.abort(code);
if (!options.isAccessPropagationPreTest) print2(`SSH session terminated`);

if (code && code !== 0) {
print2(
`Failed to establish an SSH session.${!options.debug ? " Use the --debug option to see additional details." : ""}`
);
} else if (!options.isAccessPropagationPreTest) {
print2(`SSH session terminated`);
}

resolve(code);
});
});
Expand Down Expand Up @@ -386,8 +389,10 @@ export const sshOrScp = async (args: {
proxyCommand,
credential
);

// Only exit if there was an error when pre-testing
if (exitCode && exitCode !== 0) {
return exitCode; // Only exit if there was an error when pre-testing
return exitCode;
}

return spawnSshNode({
Expand Down

0 comments on commit f3f18bf

Please sign in to comment.