Skip to content

Port the make_callback test addon from #219 and enable node-api/test_async in node-tests #403

Description

@kraenhansen

Two test-coverage follow-ups deferred from #398. Both validate functionality that Hermes' first-party Node-API implementation provides on its own (independent of the hermes_napi_host integration), so they were split out as test-infrastructure work.

1. Port the make_callback test addon from #219

napi_async_init / napi_async_destroy / napi_make_callback are provided natively by the vendored Hermes since the static_h adoption (the injector binds the full symbol surface), which obsoletes #219's host-side C++ implementation — but its test addon (tests/make_callback/: addon.c adapted from Node's own test plus a promise-less driver asserting receiver/argument/return-value plumbing) ports directly to the packages/node-addon-examples/tests/<name>/ pattern established there and in #398:

Expected to pass as-is against next — a failure would be a real conformance finding against Hermes' implementation.

2. Enable node-api/test_async in packages/node-tests

The entry exists but is commented out in scripts/copy-tests.mts's ALLOW_LIST. Two independent blockers:

  • common shims: the bundling pipeline aliases ../../common to packages/node-tests/common.ts, which currently only exports buildType. Upstream test.js uses common.mustCall. A faithful mustCall/mustCallAtLeast/mustNotCall needs a home for its verification step: upstream checks call counts at process exit, which has no analogue in the long-lived mocha-remote app — the shim needs a per-test verification hook wired into the generated suite (e.g. an afterEach-style flush exposed from common.ts).
  • <uv.h> in the C side: upstream test_async.c includes <uv.h> directly, so enabling it also needs a small uv shim along the lines of the pthread-based one written for tests/threadsafe-function/addon.c in Implement hermes_napi_host for async work and thread-safe functions #398 (or an upstream contribution making the test buildable without libuv).

Note on value: the behavioral coverage largely overlaps the hand-written tests/async addon (create/queue/cancel/delete, cancel-while-queued via pool saturation — upstream's MAX_CANCEL_THREADS 6 trick is the same one tests/async already uses — plus the #398 additions for thread identity and cancel-while-running). The win from enabling the upstream suite is conformance tracking against Node itself rather than new coverage, which is also why it wasn't a blocker for #398.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions