Skip to content

Commit 03b6e8e

Browse files
author
Loïc Mangeonjean
committed
fix: retry publishing
1 parent 045eb7c commit 03b6e8e

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

release.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,22 @@ async function publishNpm(version: string, tag: string) {
4444

4545
$.cwd = libDir
4646

47-
try {
48-
await $`npm publish --tag "${tag}" --access public --provenance`
49-
} catch (err) {
50-
if (
51-
err instanceof ProcessOutput &&
52-
err.stderr.includes('You cannot publish over the previously published versions')
53-
) {
54-
// ignore, it's an internal retry from npm that fails
55-
} else {
56-
throw err
47+
for (let retry = 0; retry < 3; ++retry) {
48+
try {
49+
await $`npm publish --tag "${tag}" --access public --provenance`
50+
break
51+
} catch (err) {
52+
if (
53+
err instanceof ProcessOutput &&
54+
err.stderr.includes('You cannot publish over the previously published versions')
55+
) {
56+
// ignore, it's an internal retry from npm that fails
57+
break
58+
} else if (err instanceof ProcessOutput && err.stderr.includes('BadRequestError')) {
59+
// retry
60+
} else {
61+
throw err
62+
}
5763
}
5864
}
5965
}

0 commit comments

Comments
 (0)