From 9b8340a5b3226722aed118625ac18dd381ec9c16 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Mon, 29 Jul 2024 19:15:36 -0700 Subject: [PATCH] Attempt to fix 'spawn error' on Windows tests --- scripts/runner.node.mjs | 58 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index 2523da8586ef01..711513436c318f 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -104,15 +104,19 @@ async function printInfo() { console.log("Glibc:", getGlibcVersion()); } console.log("Hostname:", getHostname()); - if (isCloud) { - console.log("Public IP:", await getPublicIp()); - console.log("Cloud:", getCloud()); - } if (isCI) { console.log("CI:", getCI()); console.log("Shard:", options["shard"], "/", options["max-shards"]); console.log("Build URL:", getBuildUrl()); console.log("Environment:", process.env); + if (isCloud) { + console.log("Public IP:", await getPublicIp()); + console.log("Cloud:", getCloud()); + } + const tailscaleIp = await getTailscaleIp(); + if (tailscaleIp) { + console.log("Tailscale IP:", tailscaleIp); + } } console.log("Cwd:", cwd); console.log("Tmpdir:", tmpPath); @@ -136,6 +140,30 @@ async function runTests() { } console.log("Bun:", execPath); + for (let i = 0; i < 10; i++) { + try { + const { error } = spawnSync(execPath, ["--version"], { + encoding: "utf-8", + timeout: spawnTimeout, + env: { + PATH: process.env.PATH, + BUN_DEBUG_QUIET_LOGS: 1, + }, + }); + if (!error) { + break; + } + throw error; + } catch (error) { + const { code } = error; + if (code === "EBUSY" || code === "UNKNOWN") { + console.log(`Bun appears to be busy, retrying... [code: ${code}]`); + await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1))); + continue; + } + } + } + const revision = getRevision(execPath); console.log("Revision:", revision); @@ -973,7 +1001,7 @@ async function getExecPathFromBuildKite(target) { if (isWindows) { await spawnSafe({ command: "powershell", - args: ["-Command", `Expand-Archive -Path ${zipPath} -DestinationPath ${releasePath}`], + args: ["-Command", `Expand-Archive -Path ${zipPath} -DestinationPath ${releasePath} -Force`], }); } else { await spawnSafe({ @@ -1298,6 +1326,26 @@ async function getPublicIp() { } } +/** + * @returns {string | undefined} + */ +function getTailscaleIp() { + try { + const { status, stdout } = spawnSync("tailscale", ["ip", "--1"], { + encoding: "utf-8", + timeout: spawnTimeout, + env: { + PATH: process.env.PATH, + }, + }); + if (status === 0) { + return stdout.trim(); + } + } catch { + // ... + } +} + /** * @param {...string} paths * @returns {string}