From 44eba020c615f0d9efe431f84ada67b81576f3f5 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 19 Sep 2023 18:23:51 +0200 Subject: [PATCH] improve publish-release (#55597) Closes WEB-1608 --- scripts/publish-release.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/publish-release.js b/scripts/publish-release.js index dc815bb06c4f3..086d9e0ff871f 100755 --- a/scripts/publish-release.js +++ b/scripts/publish-release.js @@ -56,6 +56,8 @@ const cwd = process.cwd() ], { stdio: 'inherit' } ) + // Return here to avoid retry logic + return } catch (err) { console.error(`Failed to publish ${pkg}`, err) @@ -69,21 +71,22 @@ const cwd = process.cwd() return } - if (retry < 3) { - const retryDelaySeconds = 15 - console.log(`retrying in ${retryDelaySeconds}s`) - await new Promise((resolve) => - setTimeout(resolve, retryDelaySeconds * 1000) - ) - await publish(pkg, retry + 1) + if (retry >= 3) { + throw err } - throw err } finally { publishSema.release() } + // Recursive call need to be outside of the publishSema + const retryDelaySeconds = 15 + console.log(`retrying in ${retryDelaySeconds}s`) + await new Promise((resolve) => + setTimeout(resolve, retryDelaySeconds * 1000) + ) + await publish(pkg, retry + 1) } - await Promise.all( + await Promise.allSettled( packageDirs.map(async (packageDir) => { const pkgJson = await readJson( path.join(packagesDir, packageDir, 'package.json')