diff --git a/src/lib/onboard.ts b/src/lib/onboard.ts index 2985e19dafe..5448138ac49 100644 --- a/src/lib/onboard.ts +++ b/src/lib/onboard.ts @@ -3539,7 +3539,7 @@ async function ensureNamedCredential( return replaceNamedCredential(envName, label, helpUrl); } -function waitForSandboxReady(sandboxName: string, attempts = 10, delaySeconds = 2): boolean { +async function waitForSandboxReady(sandboxName: string, attempts = 10, delaySeconds = 2): Promise { for (let i = 0; i < attempts; i += 1) { const podPhase = runCaptureOpenshell( [ @@ -3558,7 +3558,7 @@ function waitForSandboxReady(sandboxName: string, attempts = 10, delaySeconds = { ignoreError: true }, ); if (podPhase === "Running") return true; - sleep(delaySeconds); + await new Promise((r) => setTimeout(r, delaySeconds * 1000)); } return false; } @@ -7984,7 +7984,7 @@ async function _setupPolicies( process.exit(1); } - if (!waitForSandboxReady(sandboxName)) { + if (!(await waitForSandboxReady(sandboxName))) { console.error(` Sandbox '${sandboxName}' was not ready for policy application.`); process.exit(1); } @@ -8022,7 +8022,7 @@ async function _setupPolicies( return; } - if (!waitForSandboxReady(sandboxName)) { + if (!(await waitForSandboxReady(sandboxName))) { console.error(` Sandbox '${sandboxName}' was not ready for policy application.`); process.exit(1); } @@ -8617,7 +8617,7 @@ async function setupPoliciesWithSelection( if (selectedPresets && selectedPresets.length > 0) { const resumeSelection = chosen || []; if (onSelection) onSelection(resumeSelection); - if (!waitForSandboxReady(sandboxName)) { + if (!(await waitForSandboxReady(sandboxName))) { console.error(` Sandbox '${sandboxName}' was not ready for policy application.`); process.exit(1); } @@ -8702,7 +8702,7 @@ async function setupPoliciesWithSelection( } if (onSelection) onSelection(chosen); - if (!waitForSandboxReady(sandboxName)) { + if (!(await waitForSandboxReady(sandboxName))) { console.error(` Sandbox '${sandboxName}' was not ready for policy application.`); process.exit(1); } @@ -8724,7 +8724,7 @@ async function setupPoliciesWithSelection( const interactiveChoice = resolvedPresets.map((p) => p.name); if (onSelection) onSelection(interactiveChoice); - if (!waitForSandboxReady(sandboxName)) { + if (!(await waitForSandboxReady(sandboxName))) { console.error(` Sandbox '${sandboxName}' was not ready for policy application.`); process.exit(1); }