Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
Closed
Labels
addonsIssues and PRs related to native addons.Issues and PRs related to native addons.c++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.
Description
Reproduction:
#include<node.h> #include<uv.h> #include<unistd.h>static v8::Persistent<v8::Promise::Resolver> persistent; voidrun(uv_work_t* req){sleep(1)} voidcallback(uv_work_t* req, int i){v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); v8::Local<v8::Promise::Resolver> local = v8::Local<v8::Promise::Resolver>::New(isolate, persistent); local->Resolve(v8::Undefined(isolate))} voidtest(const v8::FunctionCallbackInfo<v8::Value>& args){v8::Isolate* isolate = args.GetIsolate(); if (persistent.IsEmpty()){persistent.Reset(isolate, v8::Promise::Resolver::New(isolate)); uv_work_t * req = (uv_work_t*) malloc(sizeof(uv_work_t)); uv_queue_work(uv_default_loop(), req, run, callback)} v8::Local<v8::Promise::Resolver> local = v8::Local<v8::Promise::Resolver>::New(isolate, persistent); args.GetReturnValue().Set(local->GetPromise())} voidinit(v8::Local<v8::Object> exports){NODE_SET_METHOD(exports, "test", test)} NODE_MODULE(addon, init)varr=require('./build/Release/addon.node');r.test().then(function(){console.log('done');});setTimeout(()=>{},5000);done should be printed after 1 seconds, but is printed after 5 seconds instead.
ranisalt, benjamingr, trofim24 and huenchao
Metadata
Metadata
Assignees
Labels
addonsIssues and PRs related to native addons.Issues and PRs related to native addons.c++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.