Skip to content

Commit 3456457

Browse files
committed
💄
1 parent a490126 commit 3456457

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ssh/nativeSSH.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ function execCommand(command: string, args?: string[], options?: { timeout?: num
4040
let abortController: AbortController | undefined;
4141
if (options?.timeout && options.timeout > 0) {
4242
abortController = new AbortController();
43-
setTimeout(() => {
44-
abortController?.abort();
45-
}, options.timeout);
43+
setTimeout(() => abortController?.abort(), options.timeout);
4644
}
4745
const process = cp.spawn(command, args, { ...options, windowsVerbatimArguments: true, signal: abortController?.signal });
4846
const stdoutDataArr: string[] = [];
@@ -55,6 +53,9 @@ function execCommand(command: string, args?: string[], options?: { timeout?: num
5553
});
5654
const completed = new Promise<{ code: number }>((resolve, reject) => {
5755
process.on('error', (err) => {
56+
if (err.name === 'AbortError') {
57+
err = new SSHCommandTimeoutError();
58+
}
5859
reject(err);
5960
});
6061
process.on('close', (code) => {

0 commit comments

Comments
 (0)