Skip to content

Commit

Permalink
feat(deployment): Upload of artifacts should be retried on failure
Browse files Browse the repository at this point in the history
Close #1749
  • Loading branch information
develar committed Jul 3, 2017
1 parent 6ed59be commit 7ffcd27
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/electron-publish/src/BintrayPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BintrayPublisher extends HttpPublisher {
return
}

let badGatewayCount = 0
let attemptNumber = 0
for (let i = 0; i < 3; i++) {
try {
return await httpExecutor.doApiRequest<any>(configureRequestOptions({
Expand All @@ -76,7 +76,7 @@ export class BintrayPublisher extends HttpPublisher {
}, this.client.auth), this.context.cancellationToken, requestProcessor)
}
catch (e) {
if (e instanceof HttpError && e.response.statusCode === 502 && badGatewayCount++ < 3) {
if (attemptNumber++ < 3 && ((e instanceof HttpError && e.response.statusCode === 502) || e.code === "EPIPE")) {
continue
}

Expand Down
7 changes: 5 additions & 2 deletions packages/electron-publish/src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class GitHubPublisher extends HttpPublisher {
}

const parsedUrl = parseUrl(release.upload_url.substring(0, release.upload_url.indexOf("{")) + "?name=" + fileName)
let badGatewayCount = 0
let attemptNumber = 0
uploadAttempt: for (let i = 0; i < 3; i++) {
try {
return await httpExecutor.doApiRequest<any>(configureRequestOptions({
Expand Down Expand Up @@ -138,10 +138,13 @@ export class GitHubPublisher extends HttpPublisher {
debug(`Artifact ${fileName} not found on GitHub, trying to upload again`)
continue
}
else if (e.response.statusCode === 502 && badGatewayCount++ < 3) {
else if (attemptNumber++ < 3 && e.response.statusCode === 502) {
continue
}
}
else if (attemptNumber++ < 3 && e.code === "EPIPE") {
continue
}

throw e
}
Expand Down

0 comments on commit 7ffcd27

Please sign in to comment.