diff --git a/cli/src/lib/deploy.ts b/cli/src/lib/deploy.ts index 20f68a7..0f176b4 100644 --- a/cli/src/lib/deploy.ts +++ b/cli/src/lib/deploy.ts @@ -345,11 +345,24 @@ async function ensureVectorizeIndex(ctx: DeployContext): Promise { throw new Error(msg); } -/** 下載 codeload tarball 解壓到暫存目錄,回傳解壓出的 repo root 路徑。*/ +/** 下載 codeload tarball 解壓到暫存目錄,回傳解壓出的 repo root 路徑。 + * + * ⚠️ Arcrun#13 P2 根因修復:codeload 的 branch tarball(tar.gz/main)由 GitHub CDN 快取, + * push 後該 ref 的 tarball 可能 stale 數分鐘。「push → 立刻 acr update」會抓到舊 tarball → + * wrangler deploy 仍回 ✓(部署成功)但 ship 的是**舊 code** → seed 還是舊數量(假綠: + * 「deploy 成功」≠「部到修好的版本」)。這正是 telegram seed 灌不進 leo21c 的真因。 + * 解法:fetch 時帶 no-cache header + 唯一 query param 強制繞過 CDN 快取,每次抓到 ref 的最新內容。*/ async function downloadRepoTarball(ref: string): Promise { - const url = `https://codeload.github.com/${ARCRUN_REPO}/tar.gz/${ref}`; + // 唯一 cache-buster query param:codeload 對不同 query 視為不同資源 → 繞過 stale CDN entry。 + const bust = `${Date.now()}-${Math.random().toString(36).slice(2)}`; + const url = `https://codeload.github.com/${ARCRUN_REPO}/tar.gz/${ref}?_cb=${bust}`; console.log(chalk.gray(` → 從 GitHub 下載最新版本(${ARCRUN_REPO}@${ref},約 10–30 秒,視網速)...`)); - const res = await fetch(url, { signal: AbortSignal.timeout(120_000) }); + const res = await fetch(url, { + signal: AbortSignal.timeout(120_000), + // 強制繞過任何中間快取,避免抓到 push 後尚未刷新的 stale tarball(#13 P2 假綠根因)。 + headers: { 'Cache-Control': 'no-cache', Pragma: 'no-cache' }, + cache: 'no-store', + }); if (!res.ok) throw new Error(`codeload HTTP ${res.status}(${url})`); const buf = Buffer.from(await res.arrayBuffer());