Skip to content

Commit

Permalink
Retry with fresh otp if publish fails (facebook#20582)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite authored and koto committed Jun 15, 2021
1 parent bfcab33 commit ab82bae
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions scripts/release/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ab82bae

Please sign in to comment.