From ee7f4696b64de1c91d5924450be1e48f01c8f196 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 05:44:14 +0000 Subject: [PATCH 1/2] queue-transport-alert: pass version secrets to cf through a pipe cf reads --secrets-file with a plain file read, and /dev/stdin failed with 'Could not read file' on the first live versions upload (nothing was uploaded or deployed). Hand cf a process-substitution pipe instead, with cf's own stdin on /dev/null, so the secrets still never touch disk or argv. Refs #6369 Co-Authored-By: Claude Opus 5.5 --- pkgs/queue-transport-alert/worker/README.md | 2 +- pkgs/queue-transport-alert/worker/deploy.mjs | 25 +++++++++++++------- pkgs/queue-transport-alert/worker/deploy.nix | 2 ++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pkgs/queue-transport-alert/worker/README.md b/pkgs/queue-transport-alert/worker/README.md index ca9711eb57..b7c3537ee6 100644 --- a/pkgs/queue-transport-alert/worker/README.md +++ b/pkgs/queue-transport-alert/worker/README.md @@ -82,7 +82,7 @@ keeps the two in step). The app stages the flake package the Nix store, then: 1. `cf workers versions create --tag git-` uploads a version - with its secrets read from stdin (`--secrets-file /dev/stdin`); + with its secrets passed through a pipe (`--secrets-file <(cat)`); nothing goes live yet. 2. `cf workers deployments create` puts that version at 100%. 3. `cf workers triggers deploy` applies the cron schedule. diff --git a/pkgs/queue-transport-alert/worker/deploy.mjs b/pkgs/queue-transport-alert/worker/deploy.mjs index d29979eb10..44b46d6092 100644 --- a/pkgs/queue-transport-alert/worker/deploy.mjs +++ b/pkgs/queue-transport-alert/worker/deploy.mjs @@ -3,7 +3,7 @@ // // cf workers versions create upload a version stamped with the git // SHA (--tag git-), its secrets -// read from stdin; nothing goes live yet +// through a pipe; nothing goes live yet // cf workers deployments create put that version at 100% // cf workers triggers deploy apply the cron schedule from the config // @@ -95,13 +95,25 @@ for (const [name, variable] of [["cf", "QTA_CF_MODULE"], ["wrangler", "QTA_WRANG symlinkSync(target, join(stage, "node_modules", name)); } -function runCf(args, { capture = false, input } = {}) { +function runCf(args, { capture = false } = {}) { return execFileSync("cf", ["-q", ...args], { cwd: stage, env, encoding: "utf8", - input, - stdio: [input === undefined ? "inherit" : "pipe", capture ? "pipe" : "inherit", "inherit"], + stdio: ["inherit", capture ? "pipe" : "inherit", "inherit"], + }); +} + +// cf reads --secrets-file with a plain file read, which fails on this +// process's stdin pipe. Hand it a fresh pipe instead: bash's process +// substitution copies our stdin (the secrets JSON) into /dev/fd/N, and +// cf itself gets /dev/null, so the values never touch disk or argv. +function runCfWithSecrets(args, secrets) { + execFileSync("bash", ["-c", 'cf -q "$@" --secrets-file <(cat) Date: Thu, 19 Nov 2026 05:45:28 +0000 Subject: [PATCH 2/2] queue-transport-alert: make the post-deploy status check survive slow connects The first live cf deploy uploaded, deployed and applied the cron, then its /status.json check failed: Node's 250 ms per-address connect window timed out every address on the laptop's network while curl got through. Give each address 5 s, retry three times, and say the version is deployed when only the check fails. Refs #6369 Co-Authored-By: Claude Opus 5.5 --- pkgs/queue-transport-alert/worker/deploy.mjs | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pkgs/queue-transport-alert/worker/deploy.mjs b/pkgs/queue-transport-alert/worker/deploy.mjs index 44b46d6092..2802979000 100644 --- a/pkgs/queue-transport-alert/worker/deploy.mjs +++ b/pkgs/queue-transport-alert/worker/deploy.mjs @@ -33,6 +33,7 @@ // the previous version's value. No secret is printed or written to disk. import { execFileSync } from "node:child_process"; import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync } from "node:fs"; +import { setDefaultAutoSelectFamilyAttemptTimeout } from "node:net"; import { homedir, tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -133,9 +134,23 @@ async function verify(versionId) { throw new Error(`post-deploy check failed: expected version ${versionId} at 100%, latest deployment serves ${serving.serving}`); } const url = `${WORKER_URL}/status.json`; - const response = await fetch(url, { headers: { "user-agent": BROWSER_UA }, signal: AbortSignal.timeout(15_000) }); - if (!response.ok) throw new Error(`post-deploy check failed: ${url} answered HTTP ${response.status}`); - const status = await response.json(); + // Node tries each address for only 250 ms by default; on the laptop's + // network that timed out every address while curl got through. + setDefaultAutoSelectFamilyAttemptTimeout(5_000); + let status; + for (let attempt = 1; ; attempt += 1) { + try { + const response = await fetch(url, { headers: { "user-agent": BROWSER_UA }, signal: AbortSignal.timeout(20_000) }); + if (!response.ok) throw new Error(`HTTP ${response.status}`); + status = await response.json(); + break; + } catch (error) { + if (attempt >= 3) { + throw new Error(`version ${versionId} is deployed, but ${url} did not answer: ${error.cause?.message ?? error.message}`); + } + await new Promise((resolve) => setTimeout(resolve, 3_000)); + } + } console.log(`verified: version ${versionId} serves 100%; ${url} reports the broker ${status.status ?? "unknown"}`); }