Skip to content

Unsafe to call napi_queue_async_work with already-queued napi_async_work #27217

Closed
@markandrus

Description

@markandrus
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    node-apiIssues and PRs related to the Node-API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions