-
Notifications
You must be signed in to change notification settings - Fork 697
BREAKING: Convert sync methods to async methods #1348
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
Conversation
lib/repository.js
Outdated
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" %} |
There was a problem hiding this comment.
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" %} |
There was a problem hiding this comment.
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.
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.
Convert the following routines to be async routines:
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