Skip to content

Commit

Permalink
fix(electron-publish): socket hang up error 422 issues in github publ…
Browse files Browse the repository at this point in the history
…ish (#6563)

* fix(electron-publish): handle plain text description from github api HTTP_ERROR_422
  • Loading branch information
baparham committed Jan 19, 2022
1 parent 93512a3 commit 39da9ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cyan-carpets-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-publish": patch
---

fix(electron-publish): handle plain text description from github api HTTP_ERROR_422 to resolve socket hang ups
12 changes: 11 additions & 1 deletion packages/electron-publish/src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class GitHubPublisher extends HttpPublisher {
requestProcessor
)
.catch(e => {
if (e.statusCode === 422 && e.description != null && e.description.errors != null && e.description.errors[0].code === "already_exists") {
if (this.doesErrorMeanAlreadyExists(e)) {
return this.overwriteArtifact(fileName, release).then(() => this.doUploadFile(attemptNumber, parsedUrl, fileName, dataLength, requestProcessor, release))
}

Expand All @@ -215,6 +215,16 @@ export class GitHubPublisher extends HttpPublisher {
})
}

private doesErrorMeanAlreadyExists(e: any) {
if (!e.description) {
return false
}
const desc = e.description
const descIncludesAlreadyExists =
(desc.includes("errors") && desc.includes("already_exists")) || (desc.errors && desc.errors.length >= 1 && desc.errors[0].code === "already_exists")
return e.statusCode === 422 && descIncludesAlreadyExists
}

private createRelease() {
return this.githubRequest<Release>(`/repos/${this.info.owner}/${this.info.repo}/releases`, this.token, {
tag_name: this.tag,
Expand Down

0 comments on commit 39da9ed

Please sign in to comment.