diff --git a/packages/kilo-vscode/script/publish.ts b/packages/kilo-vscode/script/publish.ts index 8741734e5a1..9f324249a84 100755 --- a/packages/kilo-vscode/script/publish.ts +++ b/packages/kilo-vscode/script/publish.ts @@ -47,7 +47,11 @@ for (const target of targets) { console.log(` ✅ Published ${target} to VS Code Marketplace`) console.log(`\n📤 Publishing ${target} to Open VSX${prerelease ? " (pre-release)" : ""}...`) - await $`npx ovsx publish ${flag} --pat ${process.env.OPENVSX_TOKEN} --packagePath ${vsixPath}` + await retry(() => $`npx ovsx publish ${flag} --pat ${process.env.OPENVSX_TOKEN} --packagePath ${vsixPath}`, { + attempts: 3, + delay: 10_000, + label: `ovsx publish ${target}`, + }) console.log(` ✅ Published ${target} to Open VSX`) } @@ -58,3 +62,16 @@ if (Script.release) { } console.log("\n✨ All targets published successfully!") + +async function retry(fn: () => Promise, opts: { attempts: number; delay: number; label: string }): Promise { + for (let i = 1; i <= opts.attempts; i++) { + try { + return await fn() + } catch (err) { + if (i === opts.attempts) throw err + console.warn(` ⚠️ ${opts.label} failed (attempt ${i}/${opts.attempts}), retrying in ${opts.delay / 1000}s...`) + await new Promise((r) => setTimeout(r, opts.delay)) + } + } + throw new Error("unreachable") +}