{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/15604","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/15604/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/15604/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/15604/events","html_url":"https://github.com/nodejs/node/issues/15604","id":260207865,"number":15604,"title":"N-API feature request: expose API to resolve promises asynchronously without napi_create_async_work","user":{"login":"rolftimmermans","id":78237,"avatar_url":"https://avatars1.githubusercontent.com/u/78237?v=4","gravatar_id":"","url":"https://api.github.com/users/rolftimmermans","html_url":"https://github.com/rolftimmermans","followers_url":"https://api.github.com/users/rolftimmermans/followers","following_url":"https://api.github.com/users/rolftimmermans/following{/other_user}","gists_url":"https://api.github.com/users/rolftimmermans/gists{/gist_id}","starred_url":"https://api.github.com/users/rolftimmermans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rolftimmermans/subscriptions","organizations_url":"https://api.github.com/users/rolftimmermans/orgs","repos_url":"https://api.github.com/users/rolftimmermans/repos","events_url":"https://api.github.com/users/rolftimmermans/events{/privacy}","received_events_url":"https://api.github.com/users/rolftimmermans/received_events","type":"User","site_admin":false},"labels":[{"id":207445406,"url":"https://api.github.com/repos/nodejs/node/labels/feature%20request","name":"feature request","color":"0D7BDE","default":false},{"id":574036893,"url":"https://api.github.com/repos/nodejs/node/labels/n-api","name":"n-api","color":"d93f0b","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2017-09-25T09:24:16Z","updated_at":"2018-02-05T22:13:07Z","closed_at":"2018-02-05T22:12:59Z","author_association":"NONE","body":"My use case: I have a socket that I'm polling with libuv `uv_poll_t`. When an event is present I want to resolve a promise.\r\n\r\nCalling `napi_resolve_deferred()` does not work for me because it does not appear to run microtasks.\r\n\r\nLooking at the test added in [this commit](https://github.com/nodejs/node/commit/a4505910d29597ff8fd9f95d4effcbf3196f63ca) I need to use the following code before resolving the promise.\r\n\r\n```\r\nv8::Isolate* isolate = v8::Isolate::GetCurrent();\r\nv8::HandleScope scope(isolate);\r\nnode::CallbackScope callback_scope(isolate, v8::Object::New(isolate), {0, 0});\r\n\r\n// resolve promise here\r\n```\r\n\r\nThis works perfectly; but now I am required to pull in both `v8.h` and `node.h`. It would be nice if there were N-API method to resolve promises with `napi_resolve_deferred()` asynchronously.\r\n\r\nNote that I am not able to use `napi_create_async_work()`/`napi_queue_async_work()` for the async code in this case."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/363239120","html_url":"https://github.com/nodejs/node/issues/15604#issuecomment-363239120","issue_url":"https://api.github.com/repos/nodejs/node/issues/15604","id":363239120,"user":{"login":"mhdawson","id":9373002,"avatar_url":"https://avatars3.githubusercontent.com/u/9373002?v=4","gravatar_id":"","url":"https://api.github.com/users/mhdawson","html_url":"https://github.com/mhdawson","followers_url":"https://api.github.com/users/mhdawson/followers","following_url":"https://api.github.com/users/mhdawson/following{/other_user}","gists_url":"https://api.github.com/users/mhdawson/gists{/gist_id}","starred_url":"https://api.github.com/users/mhdawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhdawson/subscriptions","organizations_url":"https://api.github.com/users/mhdawson/orgs","repos_url":"https://api.github.com/users/mhdawson/repos","events_url":"https://api.github.com/users/mhdawson/events{/privacy}","received_events_url":"https://api.github.com/users/mhdawson/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T22:13:06Z","updated_at":"2018-02-05T22:13:06Z","author_association":"OWNER","body":"@rolftimmermans, finally got back to this, resolved issues in tests and landed it."}}
{"actor":{"display_login":"mhdawson"}}