Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

build: warm the packaged cloudflared before its version check

waynea483d01f6b4f
diff --git a/scripts/after-pack.mjs b/scripts/after-pack.mjs
index 8889676cb7..2e0560c5be 100644
--- a/scripts/after-pack.mjs
+++ b/scripts/after-pack.mjs
@@ -1,4 +1,5 @@
import { chmod, lstat, readFile, readdir } from "node:fs/promises";
+import { spawnSync } from "node:child_process";
import path from "node:path";
import { LICENSE_FILES } from "./cua-linux-release.mjs";
import {
@@ -56,6 +57,12 @@ async function validateCloudflared(resources, platform, required) {
if (!allowed?.has(target)) {
throw new Error(`Packaged ${platform} app contains the wrong cloudflared target: ${target}`);
}
+ // A freshly copied binary can miss the 10 s version check while macOS assesses
+ // it for the first time. One long-timeout run here absorbs that delay; the
+ // real check below stays unchanged.
+ if (target === `${process.platform}-${process.arch}`) {
+ spawnSync(executable, ["version"], { timeout: 30_000, stdio: "ignore" });
+ }
verifyCloudflaredExecutable(executable, target);
const licenses = path.join(resources, "licenses");