From fdca98d95ce1e1a62c2272bca5327fd5d6daa256 Mon Sep 17 00:00:00 2001 From: hkobew Date: Thu, 7 Nov 2024 15:03:19 -0500 Subject: [PATCH] add timeout to child process --- packages/core/src/awsService/ec2/sshKeyPair.ts | 1 + packages/core/src/shared/utilities/pathFind.ts | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/core/src/awsService/ec2/sshKeyPair.ts b/packages/core/src/awsService/ec2/sshKeyPair.ts index 45565aa6e41..d770b2b5ffa 100644 --- a/packages/core/src/awsService/ec2/sshKeyPair.ts +++ b/packages/core/src/awsService/ec2/sshKeyPair.ts @@ -80,6 +80,7 @@ export class SshKeyPair { } return !(await tryRun('ssh-keygen', ['-t', keyType, '-N', '', '-q', '-f', keyPath], 'yes', 'unknown key type', { onStdout: overrideKeys, + timeout: new Timeout(3000), })) } diff --git a/packages/core/src/shared/utilities/pathFind.ts b/packages/core/src/shared/utilities/pathFind.ts index 540ad6b7c19..b1097810d3d 100644 --- a/packages/core/src/shared/utilities/pathFind.ts +++ b/packages/core/src/shared/utilities/pathFind.ts @@ -11,7 +11,6 @@ import { GitExtension } from '../extensions/git' import { Settings } from '../settings' import { getLogger } from '../logger/logger' import { mergeResolvedShellPath } from '../env/resolveEnv' -import { Timeout } from './timeoutUtils' /** Full path to VSCode CLI. */ let vscPath: string @@ -33,13 +32,9 @@ export async function tryRun( p: string, args: string[], logging: 'yes' | 'no' | 'noresult' = 'yes', - timeout?: Timeout, expected?: string, opt?: ChildProcessOptions ): Promise { - timeout?.onCompletion(() => { - throw new Error(`tryRun timed out: ${p} ${args.join(' ')}`) - }) const proc = new ChildProcess(p, args, { logging: 'no' }) const r = await proc.run({ ...opt,