Skip to content

Commit

Permalink
fix(appflow): fix an issue where a network connectivity issue could c… (
Browse files Browse the repository at this point in the history
#4520)

* fix(appflow): fix an issue where a network connectivity issue could cause an appflow build to fail incorrectly

* move the warning up before the error
  • Loading branch information
nphyatt committed Aug 20, 2020
1 parent eda29f8 commit 8634fde
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 20 deletions.
32 changes: 22 additions & 10 deletions packages/@ionic/cli/src/commands/deploy/build.ts
Expand Up @@ -159,17 +159,29 @@ Apart from ${input('--commit')}, every option can be specified using the full na
const ws = this.env.log.createWriteStream(LOGGER_LEVELS.INFO, false);

let isCreatedMessage = false;
let errorsEncountered = 0;
while (!(build && (build.state === 'success' || build.state === 'failed'))) {
await sleep(5000);
build = await this.getDeployBuild(appflowId, buildId, token);
if (build && build.state === 'created' && !isCreatedMessage) {
ws.write(chalk.yellow('Concurrency limit reached: build will start as soon as other builds finish.'));
isCreatedMessage = true;
}
const trace = build.job.trace;
if (trace.length > start) {
ws.write(trace.substring(start));
start = trace.length;
try {
await sleep(5000);
build = await this.getDeployBuild(appflowId, buildId, token);
if (build && build.state === 'created' && !isCreatedMessage) {
ws.write(chalk.yellow('Concurrency limit reached: build will start as soon as other builds finish.'));
isCreatedMessage = true;
}
const trace = build.job.trace;
if (trace.length > start) {
ws.write(trace.substring(start));
start = trace.length;
}
errorsEncountered = 0;
} catch (e) {
// Retry up to 3 times in the case of an error.
errorsEncountered++;
ws.write(chalk.yellow(`Encountered error: ${e} while fetching build data retrying.`));
if (errorsEncountered >= 3) {
ws.write(chalk.red(`Encountered ${errorsEncountered} errors in a row. Job will now fail.`));
throw e;
}
}
}
ws.end();
Expand Down
32 changes: 22 additions & 10 deletions packages/@ionic/cli/src/commands/package/build.ts
Expand Up @@ -340,17 +340,29 @@ This can be used only together with build type ${input('release')} for Android a
const ws = this.env.log.createWriteStream(LOGGER_LEVELS.INFO, false);

let isCreatedMessage = false;
let errorsEncountered = 0;
while (!(build && (build.state === 'success' || build.state === 'failed'))) {
await sleep(5000);
build = await this.getPackageBuild(appflowId, buildId, token);
if (build && build.state === 'created' && !isCreatedMessage) {
ws.write(chalk.yellow('Concurrency limit reached: build will start as soon as other builds finish.'));
isCreatedMessage = true;
}
const trace = build.job.trace;
if (trace.length > start) {
ws.write(trace.substring(start));
start = trace.length;
try {
await sleep(5000);
build = await this.getPackageBuild(appflowId, buildId, token);
if (build && build.state === 'created' && !isCreatedMessage) {
ws.write(chalk.yellow('Concurrency limit reached: build will start as soon as other builds finish.'));
isCreatedMessage = true;
}
const trace = build.job.trace;
if (trace.length > start) {
ws.write(trace.substring(start));
start = trace.length;
}
errorsEncountered = 0;
} catch (e) {
// Retry up to 3 times in the case of an error.
errorsEncountered++;
ws.write(chalk.yellow(`Encountered error: ${e} while fetching build data retrying.`));
if (errorsEncountered >= 3) {
ws.write(chalk.red(`Encountered ${errorsEncountered} errors in a row. Job will now fail.`));
throw e;
}
}
}
ws.end();
Expand Down

0 comments on commit 8634fde

Please sign in to comment.