Skip to content

Commit a59da21

Browse files
committed
refactor: simplify test ssm connection
1 parent 7c2018c commit a59da21

File tree

1 file changed

+4
-8
lines changed
  • packages/core/src/shared/extensions

1 file changed

+4
-8
lines changed

packages/core/src/shared/extensions/ssh.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,16 @@ export async function testSsmConnection(
137137
user: string,
138138
session: SSM.StartSessionResponse
139139
): Promise<ChildProcessResult | never> {
140+
const env = { SESSION_ID: session.SessionId, STREAM_URL: session.StreamUrl, TOKEN: session.TokenValue }
141+
const process = new ProcessClass(sshPath, ['-T', `${user}@${hostname}`, 'echo "test connection succeeded" && exit'])
140142
try {
141-
const env = { SESSION_ID: session.SessionId, STREAM_URL: session.StreamUrl, TOKEN: session.TokenValue }
142-
const result = await new ProcessClass(sshPath, [
143-
'-T',
144-
`${user}@${hostname}`,
145-
'echo "test connection succeeded" && exit',
146-
]).run({
143+
return await process.run({
147144
spawnOptions: {
148145
env,
149146
},
150147
})
151-
return result
152148
} catch (error) {
153-
throw new SshError('SSH connection test failed', { cause: error as Error, code: 'SSMTestConnectionFailed' })
149+
throw new SshError('SSH connection test failed', { cause: error as Error })
154150
}
155151
}
156152

0 commit comments

Comments
 (0)