Skip to content

Commit

Permalink
fix(electron-publish): Unable to publish assets to Github (ReleaseAss…
Browse files Browse the repository at this point in the history
…et asset_already_exists)

Close #3559
  • Loading branch information
develar committed Jul 1, 2019
1 parent c5c2eeb commit 1bd73c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/builder-util-runtime/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export class HttpError extends Error {
constructor(readonly statusCode: number, message: string = `HTTP error: ${HTTP_STATUS_CODES.get(statusCode) || statusCode}`, readonly description: any | null = null) {
super(message)

this.name = "HttpError"
this.name = "HttpError";
(this as NodeJS.ErrnoException).code = `HTTP_ERROR_${statusCode}`
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/electron-publish/src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ export class GitHubPublisher extends HttpPublisher {
}, this.token), this.context.cancellationToken, requestProcessor)
}
catch (e) {
if (e instanceof HttpError && e.statusCode === 422 && e.description != null && e.description.errors != null && e.description.errors[0].code === "already_exists") {
if ((e as any).statusCode === 422 && e.description != null && e.description.errors != null && e.description.errors[0].code === "already_exists") {
await this.overwriteArtifact(fileName, release)
continue
}

if (!(attemptNumber++ < 3 && (e instanceof HttpError || (e.code === "EPIPE" || e.code === "ECONNRESET")))) {
if (!(attemptNumber++ < 3 && ((e.code != null && e.code.startsWith("HTTP_ERROR_")) || e.code === "EPIPE" || e.code === "ECONNRESET"))) {
throw e
}
}
Expand Down

3 comments on commit 1bd73c9

@ethernomad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has broken publishing assets to GitHub:

Error: Cannot cleanup: 
Error #1 --------------------------------------------------------------------------------
HttpError: 422 Unprocessable Entity
{
  "message": "Validation Failed",
  "request_id": "897A:7E1B:DE2E5:13D176:5D1AE5B2",
  "documentation_url": "https://developer.github.com/v3",
  "errors": [
    {
      "resource": "ReleaseAsset",
      "code": "already_exists",
      "field": "name"
    }
  ]
}

@quanglam2807
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethernomad Which version of electron-builder are you using? This commit actually fixed that bug.

@ethernomad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builder-util-runtime@8.3.0 doesn't work for me:
https://travis-ci.com/mix-blockchain/mix-acuity/builds/118496024
8.2.5 does:
https://travis-ci.com/mix-blockchain/mix-acuity/builds/118498974

Using electron-builder@20.44.4

Please sign in to comment.