From 2a51d67da07256c71ec7d20a12b186b9795e04fd Mon Sep 17 00:00:00 2001 From: uncle6me-web Date: Mon, 29 Jun 2026 21:04:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20cache-bust=20codeload=20tarball?= =?UTF-8?q?=20=E4=B8=8B=E8=BC=89=EF=BC=8C=E4=BF=AE=20seed=20=E5=81=87?= =?UTF-8?q?=E7=B6=A0=E6=A0=B9=E5=9B=A0=20(Arcrun#13=20P2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:acr update / init 從 codeload.github.com/.../tar.gz/main 抓部署源,該 branch tarball 由 GitHub CDN 快取,push 後可 stale 數分鐘。「push→立刻 acr update」抓到舊 tarball → wrangler deploy 仍回 ✓ 但 ship 舊 code → /init/seed 只灌 23(舊種子數, 不含 telegram/line_notify/kbdb)。「deploy 成功」≠「部到修好的版本」= 假綠同一類。 實證:leo21c GET /auth-recipes 部署後仍持久回 23、無 telegram(非傳播延遲); source main 已含 27 個種子(git show main 核實),但部署的是舊 bundle。 修:downloadRepoTarball 加 no-cache header + cache: 'no-store' + 唯一 _cb query param,強制繞過 CDN stale entry,每次抓 ref 的最新內容。 待 leo21c 驗:push 此修 + acr update → /auth-recipes 應變 26+(含 telegram)。 Co-Authored-By: Claude Opus 4.8 (1M context) --- cli/src/lib/deploy.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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());