Skip to content

Implement napi_cancel_async_work #59

Description

@kraenhansen
No description provided.

Activity

  1. kraenhansen commented on Aug 12, 2026

    @kraenhansen
    CollaboratorAuthor

    Implemented on next. Hermes' first-party Node-API provides napi_cancel_async_work (API/napi/hermes_napi_async_work.cpp, adopted in #372), and #398 supplies the cancel_work hook behind it: the item is removed from the worker pool queue under the same mutex the workers pop it with, and the napi_cancelled completion is delivered asynchronously on the JS thread — matching Node, where a cancelled complete callback still runs on a later tick. Work already picked up by a worker cannot be cancelled and surfaces napi_generic_failure, as in Node (packages/host/cpp/HermesNapiHost.cpp).

    Covered by packages/node-addon-examples/tests/async (deterministic cancel-while-queued and cancel-of-running-work cases) and the Catch2 suite in packages/host/tests.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions