Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe to call napi_queue_async_work with already-queued napi_async_work #27217

Closed
markandrus opened this issue Apr 13, 2019 · 0 comments
Closed
Labels
node-api Issues and PRs related to the Node-API.

Comments

@markandrus
Copy link

  • Version: v10.11.0
  • Platform: macOS

Hi, it looks like it's unsafe to call napi_queue_async_work twice with the same napi_async_work if the first napi_async_complete_callback has yet to fire. I ran into this issue when porting my Native Addon from NAN to N-API. I can work around it easily, but it took a while to track down (all I was seeing was EXC_BAD_ACCESS). Perhaps the documentation should be updated to reflect this? Here's one option (new text in bold):

This API requests that the previously allocated work be scheduled for execution. Do not call this API again if the work is not yet canceled or completed.

I haven't actually tested the cancel case.

@ChALkeR ChALkeR added doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API. and removed doc Issues and PRs related to the documentations. labels Apr 13, 2019
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue May 13, 2019
Add note to `napi_queue_async_work()` indicating that, upon successful
return, it must not be called again with the same work item.

Fixes: nodejs#27217
PR-URL: nodejs#27582
targos pushed a commit that referenced this issue May 14, 2019
Add note to `napi_queue_async_work()` indicating that, upon successful
return, it must not be called again with the same work item.

Fixes: #27217
PR-URL: #27582
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node-api Issues and PRs related to the Node-API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants