From fc07b070a09396e60126dd75641472f0c7504edf Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Wed, 13 Jan 2021 13:54:56 -0600 Subject: [PATCH] Retry with fresh otp if publish fails (#20582) Currently, if publishing a package fails, the script crashes, and the user must start it again from the beginning. Usually this happens because the one-time password has timed out. With this change, the user will be prompted for a fresh otp, and the script will resume publishing. --- scripts/release/publish.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/release/publish.js b/scripts/release/publish.js index e51df5c45f..9ec9330a09 100755 --- a/scripts/release/publish.js +++ b/scripts/release/publish.js @@ -48,8 +48,22 @@ const run = async () => { await confirmVersionAndTags(params); await validateSkipPackages(params); await checkNPMPermissions(params); - const otp = await promptForOTP(params); - await publishToNPM(params, otp); + + while (true) { + try { + const otp = await promptForOTP(params); + await publishToNPM(params, otp); + break; + } catch (error) { + console.error(error.message); + console.log(); + console.log( + theme.error`Publish failed. Enter a fresh otp code to retry.` + ); + continue; + } + } + await updateStableVersionNumbers(params); await printFollowUpInstructions(params); } catch (error) {