Skip to content

Commit fc07b07

Browse files
authored
Retry with fresh otp if publish fails (facebook#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.
1 parent e6ed2bc commit fc07b07

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/release/publish.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,22 @@ const run = async () => {
4848
await confirmVersionAndTags(params);
4949
await validateSkipPackages(params);
5050
await checkNPMPermissions(params);
51-
const otp = await promptForOTP(params);
52-
await publishToNPM(params, otp);
51+
52+
while (true) {
53+
try {
54+
const otp = await promptForOTP(params);
55+
await publishToNPM(params, otp);
56+
break;
57+
} catch (error) {
58+
console.error(error.message);
59+
console.log();
60+
console.log(
61+
theme.error`Publish failed. Enter a fresh otp code to retry.`
62+
);
63+
continue;
64+
}
65+
}
66+
5367
await updateStableVersionNumbers(params);
5468
await printFollowUpInstructions(params);
5569
} catch (error) {

0 commit comments

Comments
 (0)