Skip to content

Commit

Permalink
Increase polling threshold for publish-prereleases (#22392)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite committed Sep 22, 2021
1 parent 5b57bc6 commit d56947e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions scripts/release/publish-using-ci-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
);
Expand All @@ -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) {
Expand Down Expand Up @@ -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}`,
Expand Down

0 comments on commit d56947e

Please sign in to comment.