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.
This commit is contained in:
parent
5b57bc6e31
commit
d56947eb2c
|
@ -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}`,
|
||||
|
|
Loading…
Reference in New Issue