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

Conversation

baparham
Copy link
Contributor

I split this up into two commits, one with the actual fix, then one refactor so you could actually understand what the if statement was looking for before calling this.overwriteArtifact

@netlify
Copy link

netlify bot commented Jan 18, 2022

✔️ Deploy Preview for car-park-attendant-cleat-11576 ready!

🔨 Explore the source changes: e88dffd

🔍 Inspect the deploy log: https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/61e733dfe3b9920007934812

😎 Browse the preview: https://deploy-preview-6563--car-park-attendant-cleat-11576.netlify.app

@changeset-bot
Copy link

changeset-bot bot commented Jan 18, 2022

🦋 Changeset detected

Latest commit: e88dffd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-publish Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@baparham
Copy link
Contributor Author

this should in theory close #4940

@baparham baparham changed the title Fix Socket Hang up error 422 issues in GitHub publish fix: socket hang up error 422 issues in github publish Jan 18, 2022
@baparham
Copy link
Contributor Author

@mmaietta can you take a look at this?

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")
doesErrorMeanAlreadyExists = doesErrorMeanAlreadyExists && descIncludesAlreadyExists
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just simplify the logic flow here to be less nested (instead of refactoring after)

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 > 0 && desc.errors[0].code === "already_exists")
	return e.statusCode === 422 && descIncludesAlreadyExists
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, that might make more sense that way, a bit easier to follow at least

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it up to be more like your suggestion

if (e.description) {
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")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand this:
desc.includes("errors") && desc.includes("already_exists")
Are we expecting a string or array for desc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the old code seemed to expect an object, (e.g. description = { ..., errors: [..., ..., ]}) but the response back from github is a string with some prose, and some JSON style notation that we really can't parse properly, so I support both ways, not really sure what to expect.

@mmaietta mmaietta merged commit 39da9ed into electron-userland:master Jan 19, 2022
@mmaietta
Copy link
Collaborator

Great work! Thank you for the contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Socket Hang up when electron-builder Release on github.
2 participants