Skip to content

Commit f1b5b7d

Browse files
committed
Wip: Strange bug on Windows Node 14 x64 in CI.
1 parent 77b81d9 commit f1b5b7d

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

generate/templates/manual/src/promise_completion.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,28 @@ NAN_METHOD(PromiseCompletion::New) {
5151

5252
// sets up a Promise to forward the promise result via the baton and callback
5353
void PromiseCompletion::Setup(v8::Local<v8::Function> thenFn, v8::Local<v8::Value> result, AsyncBaton *baton, Callback callback) {
54+
Nan::HandleScope scope;
55+
56+
std::cout << "Entering PromiseCompletion::Setup" << std::endl;
57+
5458
this->callback = callback;
5559
this->baton = baton;
5660

5761
v8::Local<v8::Object> promise = Nan::To<v8::Object>(result).ToLocalChecked();
5862

5963
v8::Local<v8::Object> thisHandle = handle();
6064

65+
std::cout << "Binding arguments" << std::endl;
66+
6167
v8::Local<v8::Value> argv[2] = {
6268
Bind(promiseFulfilled, thisHandle),
6369
Bind(promiseRejected, thisHandle)
6470
};
6571

72+
std::cout << "Calling thenFn" << std::endl;
6673
// call the promise's .then method with resolve and reject callbacks
6774
Nan::Call(Nan::Callback(thenFn), promise, 2, argv);
75+
std::cout << "Called then function" << std::endl;
6876
}
6977

7078
// binds an object to be the context of the function.
@@ -84,6 +92,7 @@ v8::Local<v8::Value> PromiseCompletion::Bind(Nan::Persistent<v8::Function> &func
8492
// calls the callback stored in the PromiseCompletion, passing the baton that
8593
// was provided in construction
8694
void PromiseCompletion::CallCallback(bool isFulfilled, const Nan::FunctionCallbackInfo<v8::Value> &info) {
95+
Nan::HandleScope scope;
8796
v8::Local<v8::Value> resultOfPromise;
8897

8998
if (info.Length() > 0) {

generate/templates/manual/src/thread_pool.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../include/thread_pool.h"
2+
#include <iostream>
23

34
ThreadPool::ThreadPool(int numberOfThreads, uv_loop_t *loop) {
45
uv_mutex_init(&workMutex);
@@ -99,4 +100,5 @@ void ThreadPool::RunLoopCallbacks() {
99100
}
100101
uv_mutex_unlock(&workMutex);
101102
}
103+
std::cout << "Exiting RunLoopCallbacks" << std::endl;
102104
}

generate/templates/partials/field_accessors.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@
213213
}
214214

215215
if(PromiseCompletion::ForwardIfPromise(result, baton, {{ cppClassName }}::{{ field.name }}_promiseCompleted)) {
216+
{% if field.name == "credentials" %}
217+
std::cout << "Forwarding credentials" << std::endl;
218+
{% endif %}
216219
return;
217220
}
218221

@@ -250,6 +253,10 @@
250253
void {{ cppClassName }}::{{ field.name }}_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result) {
251254
Nan::HandleScope scope;
252255

256+
{% if field.name == "credentials" %}
257+
std::cout << "promise completed for credentials" << std::endl;
258+
{% endif %}
259+
253260
{{ field.name|titleCase }}Baton* baton = static_cast<{{ field.name|titleCase }}Baton*>(_baton);
254261
{% if field.return.type == "void" %}
255262
baton->Done();

generate/templates/templates/struct_header.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <queue>
66
#include <utility>
77
#include <unordered_map>
8+
#include <iostream>
89

910
#include "async_baton.h"
1011
#include "callback_wrapper.h"

test/tests/remote.js

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ describe("Remote", function() {
346346

347347
if (!isNode8) {
348348
it("will reject if credentials promise rejects", function() {
349+
this.timeout(60000);
349350
var repo = this.repository;
350351
var branch = "should-not-exist";
351352
return Remote.lookup(repo, "origin")
@@ -356,10 +357,20 @@ describe("Remote", function() {
356357
callbacks: {
357358
credentials: function(url, userName) {
358359
var test = Promise.resolve("test")
359-
.then(function() { return; })
360-
.then(function() { return; })
361-
.then(function() { return; })
362360
.then(function() {
361+
console.log("1");
362+
return;
363+
})
364+
.then(function() {
365+
console.log("2");
366+
return;
367+
})
368+
.then(function() {
369+
console.log("3");
370+
return;
371+
})
372+
.then(function() {
373+
console.log("4");
363374
return Promise.reject(new Error("failure case"));
364375
});
365376
return test;
@@ -390,10 +401,22 @@ describe("Remote", function() {
390401
callbacks: {
391402
credentials: function(url, userName) {
392403
var test = Promise.resolve()
393-
.then(Promise.resolve.bind(Promise))
394-
.then(Promise.resolve.bind(Promise))
395-
.then(Promise.resolve.bind(Promise))
396-
.then(Promise.reject.bind(Promise));
404+
.then(() => {
405+
console.log("1");
406+
return Promise.resolve();
407+
})
408+
.then(() => {
409+
console.log("2");
410+
return Promise.resolve();
411+
})
412+
.then(() => {
413+
console.log("3");
414+
return Promise.resolve();
415+
})
416+
.then(() => {
417+
console.log("4");
418+
return Promise.reject();
419+
});
397420
return test;
398421
},
399422
certificateCheck: () => 0

0 commit comments

Comments
 (0)