Native v8::Promise Result is my question but the solution is not working. It gets stuck in the while loop which makes me think that PerformMicrotaskCheckpoint is not causing the promise to resolve itself. Here is my code:
v8::Locker locker(isolate);
v8::Isolate::Scope isolateScope(isolate);
v8::HandleScope handleScope(isolate);
v8::Local<v8::Context> localContext = v8::Local<v8::Context>::New(isolate, context);
v8::Context::Scope contextScope(localContext);
escape(html);
std::string code = "const html = '" + html + "';";
code += "render(html);";
v8::Local<v8::Value> returnVal = run(code, localContext);
v8::Local<v8::Promise> promise = returnVal.As<v8::Promise>();
while (promise->State() == v8::Promise::kPending) {
isolate->PerformMicrotaskCheckpoint();
}
return promise->State() != v8::Promise::kRejected ? *v8::String::Utf8Value(isolate, promise->Result()) : "";
Also the node library I am using is different. I am using https://github.com/nodejs/node not Nan.