fix(deploy): cache-bust codeload tarball 下載,修 seed 假綠根因 (Arcrun#13 P2)
根因: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) <noreply@anthropic.com>
This commit is contained in:
+16
-3
@@ -345,11 +345,24 @@ async function ensureVectorizeIndex(ctx: DeployContext): Promise<void> {
|
|||||||
throw new Error(msg);
|
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<string> {
|
async function downloadRepoTarball(ref: string): Promise<string> {
|
||||||
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 秒,視網速)...`));
|
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})`);
|
if (!res.ok) throw new Error(`codeload HTTP ${res.status}(${url})`);
|
||||||
|
|
||||||
const buf = Buffer.from(await res.arrayBuffer());
|
const buf = Buffer.from(await res.arrayBuffer());
|
||||||
|
|||||||
Reference in New Issue
Block a user