From d56947eb2c2a0d1599975b90a353b06b58c0e00c Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 21 Sep 2021 21:43:59 -0400 Subject: [PATCH] Increase polling threshold for publish-prereleases (#22392) The publish-preleases command prints the URL of the publish workflow so that you can visit the page and follow along. But it can take a few seconds before the workflow ID is available, after you create the pipeline. So the script polls the workflow endpoint until it's available. The current polling limit is too low so I increased it. I also updated the error message to provide more info. --- scripts/release/publish-using-ci-workflow.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/release/publish-using-ci-workflow.js b/scripts/release/publish-using-ci-workflow.js index 48a834ba1f19f..d7f87b48b094b 100644 --- a/scripts/release/publish-using-ci-workflow.js +++ b/scripts/release/publish-using-ci-workflow.js @@ -22,8 +22,8 @@ function sleep(ms) { async function getPublishWorkflowID(pipelineID) { // Since we just created the pipeline in a POST request, the server may 404. - // Try up to three times before giving up. - for (let i = 0; i < 3; i++) { + // Try a few times before giving up. + for (let i = 0; i < 20; i++) { const pipelineWorkflowsResponse = await fetch( `https://circleci.com/api/v2/pipeline/${pipelineID}/workflow` ); @@ -37,7 +37,7 @@ async function getPublishWorkflowID(pipelineID) { // CircleCI server may be stale. Wait a sec and try again. await sleep(1000); } - throw new Error('Failed to create CircleCI workflow.'); + return null; } async function pollUntilWorkflowFinishes(workflowID) { @@ -108,6 +108,20 @@ async function main() { 2 * 1000 // Estimated time: 2 seconds, ); + if (workflowID === null) { + console.warn( + theme.yellow( + 'Created a CI pipeline to publish the packages, but the script timed ' + + "out when requesting the associated workflow ID. It's still " + + 'possible the workflow was created.\n\n' + + 'Visit ' + + 'https://app.circleci.com/pipelines/github/facebook/react?branch=main ' + + 'for a list of the latest workflows.' + ) + ); + process.exit(1); + } + await logPromise( pollUntilWorkflowFinishes(workflowID), theme`{header Publishing in CI workflow}: https://app.circleci.com/pipelines/workflows/${workflowID}`,