Eliminate promise polling#854
Conversation
|
This looks fantastic! A+ man. Can you switch the clones tests over to using another library to confirm that we work with other promise implementations? Bluebird or then would be good. |
|
👯 ! |
|
I would also test vanilla node promises (since they exist in 0.12+, which is where our support starts). |
b1fb458 to
3865ab2
Compare
|
Good call! I tested with native promises since that was the easiest, and got it to work. On the native side I just needed to replace a It turns out (at least in node 4.2.3 that I was testing with) that native Promises don't let you call you get a crash. And we had test code like this: The last line results in the same crash. Use cases like this just need to be modified to pass Would you like me to replace |
|
Just FYI, the last thing I am working on is ensuring that |
|
Actually, I may have been wrong about needing |
|
Yeah... best I can tell, |
334f8b6 to
1849693
Compare
|
Found and fixed the memory leak - the majority of the problem was with the fact that when using a Taking off the WIP, but someone better at Nan/v8 than me might want to take a close look at the code. |
966222b to
25a9ba2
Compare
|
@srajko |
93bd8d2 to
8dae154
Compare
|
AppVeyor timed out. I'll re-run |
There was a problem hiding this comment.
I feel like these should bind to result and not thisHandle. They are instance properties of result and we're rebinding the context of them.
There was a problem hiding this comment.
promiseFulfilled and promiseRejected are instance properties of PromiseCompletion objects - https://github.com/srajko/nodegit/blob/8dae154aa00b5c23f482b746ba4efcfb524a812d/generate/templates/manual/src/promise_completion.cc#L13-L14 https://github.com/srajko/nodegit/blob/8dae154aa00b5c23f482b746ba4efcfb524a812d/generate/templates/manual/src/promise_completion.cc#L97-L103
We need to bind thisHandle to them so that they can access the PromiseCompletion instance here - https://github.com/srajko/nodegit/blob/8dae154aa00b5c23f482b746ba4efcfb524a812d/generate/templates/manual/src/promise_completion.cc#L92-L94
There might be a better way to do the binding though - using the JS Function.bind method was the best I could come up with, short of leaking memory by creating a function template for each instance of PromiseCompletion :-)
There was a problem hiding this comment.
So I was mistaken about what was going on. I thought this was related to how the Promise.resolve functions passed in now were being bound to themselves in JS. Apparently that is a requirement of Chromium and is Promise library implementation specific. The actual then library does not have this requirement and that was the backing lib for nodegit-promise which is why we didn't need to bind the functions being passed in during tests. With that resolved I'm good with this PR.
|
https://github.com/nodegit/nodegit/pull/854/files#r49623812 might fix the binding issue? |
Eliminates the polling of promises when executing javascript callbacks from within async libgit2 calls. Replaces with a system that forwards the promise result / rejection reason to the native layer directly.
This should remove our dependency on the nodegit-promise library.