Skip to content

Commit 7f0698c

Browse files
committed
dont use waitUntil
1 parent ab11aca commit 7f0698c

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

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

Lines changed: 2 additions & 13 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, waitUntil } from '../../shared/utilities/timeoutUtils'
9+
import { Timeout } from '../../shared/utilities/timeoutUtils'
1010
import { findAsync } from '../../shared/utilities/collectionUtils'
1111
import { RunParameterContext } from '../../shared/utilities/processUtils'
1212

@@ -37,19 +37,8 @@ export class SshKeyPair {
3737
if (!keyGenerated) {
3838
throw new ToolkitError('ec2: Unable to generate ssh key pair with either ed25519 or rsa')
3939
}
40-
// waitUntil avoids Windows race condition of using key right after creation.
41-
const maxRetries = 5
42-
await waitUntil(
43-
async () => {
44-
return await fs.exists(keyPath)
45-
},
46-
{ maxRetries: maxRetries }
47-
)
48-
4940
if (!(await fs.exists(keyPath))) {
50-
throw new ToolkitError(
51-
`ec2: Failed to generate keys, resulting key not found at ${keyPath} after ${maxRetries} tries`
52-
)
41+
throw new ToolkitError(`ec2: Failed to generate keys, resulting key not found at ${keyPath}`)
5342
}
5443
}
5544

packages/core/src/shared/utilities/timeoutUtils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ interface WaitUntilOptions {
191191
readonly interval?: number
192192
/** Wait for "truthy" result, else wait for any defined result including `false` (default: true) */
193193
readonly truthy?: boolean
194-
/** Max retries (default: unlimited) */
195-
readonly maxRetries?: number
196194
}
197195

198196
/**
@@ -205,7 +203,7 @@ interface WaitUntilOptions {
205203
*/
206204
export async function waitUntil<T>(fn: () => Promise<T>, options: WaitUntilOptions): Promise<T | undefined> {
207205
const opt = { timeout: 5000, interval: 500, truthy: true, ...options }
208-
for (let i = 0; options.maxRetries ?? true; i++) {
206+
for (let i = 0; true; i++) {
209207
const start: number = globals.clock.Date.now()
210208
let result: T
211209

0 commit comments

Comments
 (0)