release: when the published version is still missing from the registry after 2 minutes, publish once more (0.8.10's publish answered 0 and left nothing)

This commit is contained in:
CRTkafa 2026-10-16 07:48:55 +08:00
parent 9059b2b32a
commit d6070cc185

View file

@ -425,7 +425,19 @@ async function npmRelease(version: string, token: string): Promise<void> {
// the registry lags a little after a publish; wait (timeout, heartbeat) until it serves the version as latest
const end = Date.now() + 5 * 60_000;
let last = 0;
let again = false;
for (;;) {
// a publish that answered 0 once left no version on the registry (0.8.10): publish once more when the version is
// still missing after 2 minutes (a second publish of a version that landed answers "cannot publish over")
if (!again && Date.now() > end - 3 * 60_000) {
const v = spawnSync('npm', ['view', `storebound@${version}`, 'version'], { encoding: 'utf8', timeout: 30_000 });
if (!(v.stdout ?? '').trim()) {
again = true;
say(`npm: ${version} is not on the registry yet: publishing once more`);
const p2 = npmRun(['publish'], token);
if (p2.code !== 0 && !/previously published|cannot publish over/i.test(p2.out)) fail(`npm publish (second try) failed: ${p2.out.trim().split('\n').slice(-4).join(' ')}`);
}
}
const r = spawnSync('npm', ['view', 'storebound', 'dist-tags.latest'], { encoding: 'utf8', timeout: 30_000 });
if ((r.stdout ?? '').trim() === version) break;
if (Date.now() > end) fail(`npm: ${version} published but the registry still serves ${(r.stdout ?? '').trim()} as latest after 5 min`);