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.
Andrew Clark committed
Jan 13, 2021 at 13:54 UTC
fc07b070a09396e60126dd75641472f0c7504edf
1 file changed
+16
-2
scripts/release/publish.js
+16
-2
@@ -48,8 +48,22 @@ const run = async () => {
48
await confirmVersionAndTags(params);
49
await validateSkipPackages(params);
50
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
+
67
await updateStableVersionNumbers(params);
68
await printFollowUpInstructions(params);
69
} catch (error) {