fix(deploy): r2 getJSON must not read transient API errors as missing objects
A CF API 502 on the manifest.json probe made publish-libs misdetect an already-published tag as unpublished and start a full republish (byte-identical immutable content, so harmless — but ~30 min of redundant uploads before a second 502 killed it). Only wrangler's definitive missing-object error now reads as absent; anything else throws. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011CC8aAnUUHcnHy3QCJtUwb
This commit is contained in:
parent
8ee8db69e6
commit
6bbef2cb52
1 changed files with 11 additions and 2 deletions
|
|
@ -135,8 +135,17 @@ export function r2Driver({ bucket, remote }) {
|
|||
run(["r2", "object", "get", `${bucket}/${key}`, "--file", dest, ...flags], {
|
||||
quiet: true,
|
||||
});
|
||||
} catch {
|
||||
return null; // not found / error → absent (expected on first publish)
|
||||
} catch (e) {
|
||||
// ONLY a definitive "no such object" reads as absent. Any other failure
|
||||
// (CF API 5xx, auth, network) must THROW: publishers branch on these
|
||||
// probes — publish-libs once misread a transient 502 on manifest.json
|
||||
// as "tag not published" and started a full republish of an existing
|
||||
// immutable tag (harmless bytes-wise, ~30 min wasted).
|
||||
const msg = `${e?.stderr ?? ""}${e?.stdout ?? ""}${e?.message ?? ""}`;
|
||||
if (/does not exist|no such object|not found|404/i.test(msg)) return null;
|
||||
throw new Error(
|
||||
`r2 get ${bucket}/${key} failed (NOT a missing-object miss): ${msg.slice(0, 400)}`,
|
||||
);
|
||||
}
|
||||
try {
|
||||
return JSON.parse(readFileSync(dest, "utf8"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue