From e2003a2b5ba1ef93a8000454ee8eb421a60ac23a Mon Sep 17 00:00:00 2001 From: "xingjian.ym" Date: Wed, 19 Aug 2026 17:33:16 +0800 Subject: [PATCH] fix: support flattened SEA layout in v2.1.229+ and retry CDN downloads Anthropic flattened the embedded file layout starting v2.1.229: cli.js now sits at the extract root instead of src/entrypoints/cli.js, so extraction fails with ENOENT on 2.1.229 and later. Fall back to the new path when the legacy one is absent. Also add curl --retry to binary downloads: transient CDN SSL errors (curl exit 35) otherwise fail the whole multi-platform build. --- scripts/fetch-and-process.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/fetch-and-process.mjs b/scripts/fetch-and-process.mjs index cba39f7..17198fe 100644 --- a/scripts/fetch-and-process.mjs +++ b/scripts/fetch-and-process.mjs @@ -1,5 +1,5 @@ import { mkdir, rm, writeFile, readFile, stat, copyFile } from 'node:fs/promises'; -import { readdirSync } from 'node:fs'; +import { readdirSync, existsSync } from 'node:fs'; import { execFileSync } from 'node:child_process'; import { join } from 'node:path'; import { extractBunSEA } from './bun-sea-extract.mjs'; @@ -54,7 +54,7 @@ function fetchJson(url) { async function downloadFile(url, destPath) { console.log(` ↓ ${url.split('/').slice(-2).join('/')}`); - execFileSync('curl', ['-sL', '--fail', '-o', destPath, url], { timeout: 600_000 }); + execFileSync('curl', ['-sL', '--fail', '--retry', '3', '--retry-delay', '2', '--retry-all-errors', '-o', destPath, url], { timeout: 600_000 }); return (await stat(destPath)).size; } @@ -219,7 +219,9 @@ export async function fetchAndProcess({ } // Verify Node.js compatibility before patching - const cliSrc = join(extractDir, 'src', 'entrypoints', 'cli.js'); + // v2.1.229+: embedded layout flattened, cli.js at extract root + const legacyCli = join(extractDir, 'src', 'entrypoints', 'cli.js'); + const cliSrc = existsSync(legacyCli) ? legacyCli : join(extractDir, 'cli.js'); const { compatible, fatal } = verifyNodeCompat(cliSrc); if (!compatible) { console.error(` ✗ ${platform} — Node.js compat check failed (${fatal} fatal)`); @@ -231,7 +233,7 @@ export async function fetchAndProcess({ // Patch cli.js const patchedPath = join(tmpDir, 'patched', `${platform}.js`); await mkdir(join(tmpDir, 'patched'), { recursive: true }); - await patchFile(join(extractDir, 'src', 'entrypoints', 'cli.js'), patchedPath); + await patchFile(cliSrc, patchedPath); extractions[platform] = { extractDir, patchedPath, binPath }; console.log(` ✓ ${platform}`);