Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

cjhoward92
Copy link
Collaborator

@cjhoward92 cjhoward92 commented Aug 8, 2017

Convert the following routines to be async routines:

  • NodeGit.Status.file
  • NodeGit.Merge.merge
  • rebase.commit
  • rebase.abort
  • Commit.amend
  • Reflog.write

This is to help avoid deadlocks as functions that read from or write to disk should be asynchronous. This is a breaking change since the functions now return a promise and not the original return value.

The addition of filters in #1331 caused issues with some core synchronous methods that cause deadlocks, such as merge and disk-reading methods.

This PR replaces #1342

return rebase.commit(null, signature);
return rebase.commit(null, signature)
.catch(function() {
// we are ignoring errors. This is to prevent issues caused by making this async
Copy link
Member

Choose a reason for hiding this comment

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

What are these errors that we are supposedly ignoring?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of them. The original synchronous method would ignore the libgit2 result and just return the Oid. We ran into issues with this change when rebasing as the EAPPLIED error is sometimes thrown when a patch is already applied. Because we switched to the asynchronous pattern the code now throws instead of returning a null Oid. This caused rebase operations to halt when trying to continue rebase in some scenarios.

package.json Outdated
@@ -65,7 +65,7 @@
"host": "https://nodegit.s3.amazonaws.com/nodegit/nodegit/"
},
"scripts": {
"babel": "babel --presets es2015 -d ./dist ./lib",
"babel": "babel --presets es2015 -d dist lib",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mohseenrm Why did you make this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

for testing purposes, you can discard them

@@ -10,6 +10,11 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {

baton->error_code = GIT_OK;
baton->error = NULL;
{%if cppClassName == "GitStatus" %}
Copy link
Member

Choose a reason for hiding this comment

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

This seems too specific. Check shouldAlloc flag. It should be able to generate this stub without adding this special condition.

@@ -260,6 +265,12 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() {
{%endeach%}
}

{%if cppClassName == "GitStatus" %}
Copy link
Member

Choose a reason for hiding this comment

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

Same here, we should be able to generate this without a special condition.

@implausible implausible merged commit 427f987 into nodegit:master Aug 16, 2017
emmax86 added a commit to emmax86/nodegit that referenced this pull request Feb 1, 2019
One example of a meaningful exception occurring in `continueRebase` is for the signing callback to throw because of an invalid key passphrase. In such chases, errors should not be swallowed.

In nodegit#1348, EAPPLIED was mentioned specifically as en error that we would like to swallow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants