Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: socket hang up error 422 issues in github publish #6563

Merged
merged 3 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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