Skip to content

Commit

Permalink
Attempt to fix 'spawn error' on Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Electroid committed Jul 30, 2024
1 parent 8efcc61 commit 9b8340a
Showing 1 changed file with 53 additions and 5 deletions.
58 changes: 53 additions & 5 deletions scripts/runner.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 9b8340a

Please sign in to comment.