From e2f71beb56670012829b50fdbe5a1eb858ed6f5b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 00:09:32 -0600 Subject: [PATCH] fix(pm-console-edge): a release says what a Worker that did not answer sent back A stand-up from nothing at dec4e883b8b6 (run 45121364544) failed: the scratch Worker answered as empty, took the version at 100%, and then "did not answer as dec4e883b8b6 (last answer: silent)" for four minutes. Production took the same commit without trouble. "Silent" covers an error page, a refusal, a timeout and no route alike, so the run could not say which it was. The wait now keeps what the last request heard (the status, the type and the start of the body, or the error when nothing came back) and says it when it gives up. This change is to the release itself, so its own deploy runs the stand-up from nothing again and will say. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF --- pm-stack/console/edge/release.mjs | 21 ++++++++++++++++++--- pm-stack/console/test/release.test.ts | 5 +++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pm-stack/console/edge/release.mjs b/pm-stack/console/edge/release.mjs index f4425a416a..05b0faf787 100644 --- a/pm-stack/console/edge/release.mjs +++ b/pm-stack/console/edge/release.mjs @@ -123,6 +123,8 @@ async function serving() { } let address = null; +/** What the last health request heard, for the line that says a wait failed. */ +let heard = "nothing asked yet"; async function health() { if (!address && process.env.PM_RELEASE_HEALTH) address = `${process.env.PM_RELEASE_HEALTH}/${worker}`; if (!address) { @@ -131,10 +133,23 @@ async function health() { if (status !== 200 || typeof sub !== "string") throw new Error("cannot read the account's workers.dev subdomain"); address = `https://${worker}.${sub}.workers.dev/console/health`; } + // What came back that was not a health answer is kept, in a line, so + // that a Worker that did not answer is not just "silent": an error + // page, a refusal and no route to it are different faults. + let res; try { - const res = await fetch(address, { signal: AbortSignal.timeout(10_000), headers: { "cache-control": "no-cache" } }); - return await res.json(); + res = await fetch(address, { signal: AbortSignal.timeout(10_000), headers: { "cache-control": "no-cache" } }); + } catch (error) { + heard = `no answer (${error.name}: ${String(error.cause?.code ?? error.cause?.message ?? error.message).slice(0, 80)})`; + return null; + } + const text = await res.text().catch(() => ""); + try { + const answer = JSON.parse(text); + heard = `http ${res.status}, ${text.slice(0, 160)}`; + return answer; } catch { + heard = `http ${res.status} ${res.headers.get("content-type") ?? "of no type"}: ${text.replace(/\s+/g, " ").slice(0, 160)}`; return null; } } @@ -147,7 +162,7 @@ async function answers(want) { if (last === want) return true; await sleep(HEALTH_WAIT_MS); } - say(`${worker} did not answer as ${want === "this" ? commit.short : want} (last answer: ${last})`); + say(`${worker} did not answer as ${want === "this" ? commit.short : want} (last answer: ${last}; it said: ${heard})`); return false; } diff --git a/pm-stack/console/test/release.test.ts b/pm-stack/console/test/release.test.ts index eadf42fbdf..3c3561e2aa 100644 --- a/pm-stack/console/test/release.test.ts +++ b/pm-stack/console/test/release.test.ts @@ -410,6 +410,11 @@ process.exit(status); // What was serving before is serving again. expect(serving(REAL)).toEqual({ kind: "app", short: "aaaaaaaaaaaa" }); expect(got.err).toContain(`${REAL} is not serving ${SHORT}`); + // And the run says what it heard in place of a health answer: an + // error page is a different fault from no route, and "silent" alone + // told them apart for nobody. + expect(got.out + got.err).toContain("(last answer: silent; it said: http 500 "); + expect(got.out + got.err).toContain("error code: 1101"); }); test("an upload that fails changes nothing that is serving", async () => {