Skip to content

Commit 8e50af1

Browse files
committed
use waitUntil
1 parent f1619e3 commit 8e50af1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/core/src/awsService/ec2/sshKeyPair.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import os from 'os'
66
import { fs, globals } from '../../shared'
77
import { ToolkitError } from '../../shared/errors'
88
import { tryRun } from '../../shared/utilities/pathFind'
9-
import { Timeout } from '../../shared/utilities/timeoutUtils'
9+
import { Timeout, waitUntil } from '../../shared/utilities/timeoutUtils'
1010
import { findAsync } from '../../shared/utilities/collectionUtils'
1111
import { RunParameterContext } from '../../shared/utilities/processUtils'
1212

@@ -37,10 +37,20 @@ export class SshKeyPair {
3737
if (!keyGenerated) {
3838
throw new ToolkitError('ec2: Unable to generate ssh key pair with either ed25519 or rsa')
3939
}
40-
// This throws on windows.
41-
// if (!(await fs.exists(keyPath))) {
42-
// throw new ToolkitError(`ec2: Failed to generate keys, resulting key not found at ${keyPath}`)
43-
// }
40+
41+
await waitUntil(
42+
async () => {
43+
return await fs.exists(keyPath)
44+
},
45+
{
46+
timeout: 29000,
47+
interval: 5000,
48+
}
49+
)
50+
51+
if (!(await fs.exists(keyPath))) {
52+
throw new ToolkitError(`ec2: Failed to generate keys, resulting key not found at ${keyPath}`)
53+
}
4454
}
4555

4656
public static async generateSshKeyPair(keyPath: string): Promise<void> {

0 commit comments

Comments
 (0)