You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the current Node-API engine functions are implemented by Hermes, this issues is tracking the implementation of the remaining runtime specific functions. Each will be tracked as a sub-issue of this "umbrella" issue.
That's a great question - somewhere in the host package for sure: packages/react-native-node-api-modules/cpp their implementation likely needs to reach in to React Native APIs - perhaps even JSI? 🤔 (If the latter is the case, we might need a weak map to lookup the jsi::Runtime based on napi_env too).
I imagine we'll be implementing these functions, grouped by their Node-API version levels - we could
start with Node-API v1 (either in order of ease of implementation or importance)
figure out what we other (React Native) APIs we'd need access to
figure out how we'd get to them from a function taking just the napi_env
Adopting Hermes' first-party Node-API (#372) and implementing hermes_napi_host (#398) covered most of what this umbrella was tracking: the runtime-specific functions are now provided by Hermes' API/napi, with React Native supplying the pieces Hermes delegates to its embedder — a worker pool behind post_work/cancel_work, the runtime's CallInvoker behind post_task and work completions, and fatal_exception. The buffer functions and napi_fatal_error remain host implementations in packages/host/cpp/RuntimeNodeApi.cpp.
Closed as completed (28) — each sub-issue has a comment pointing at what implements it:
hermes_napi.cpp — returns napi_generic_failure, no libuv loop by design
Test coverage for the new surface: packages/node-addon-examples/tests/async, .../tests/threadsafe-function (a port of Node's test_threadsafe_function), .../tests/buffers (a port of test_buffer), and the Catch2 suite in packages/host/tests exercising the host contract on plain Linux.
Still open (2):
Implement napi_get_node_version #67napi_get_node_version — the host shim returns napi_generic_failure and shadows Hermes' working implementation in the generated injector. Policy call: drop the shim or keep the failure. Details in the issue.
Implement napi_module_register #70napi_module_register — Hermes records the module, but our loader never reads it back, so the deprecated registration path still fails to load an addon. Details in the issue.
Two caveats recorded on the closed issues rather than left implicit: Buffer fidelity versus a real Buffer is still #171 (the host's napi_is_buffer is also looser than Node's), and tsfn ref/unref are tracked but inert since React Native has no loop lifetime to model (#82, #84).
Activity
napi_async_destroy#57napi_async_init#58napi_cancel_async_work#59napi_create_async_work#60napi_create_buffer#61napi_create_buffer_copy#62napi_create_external_buffer#63napi_delete_async_work#64napi_fatal_error#65napi_get_buffer_info#66napi_get_node_version#678 remaining items
napi_open_callback_scope#76napi_remove_env_cleanup_hook#77napi_acquire_threadsafe_function#78napi_call_threadsafe_function#79napi_create_threadsafe_function#80napi_get_threadsafe_function_context#81napi_ref_threadsafe_function#82napi_release_threadsafe_function#83napi_unref_threadsafe_function#84napi_add_async_cleanup_hook#85napi_remove_async_cleanup_hook#86shirakaba commentedon May 25, 2025
Reference implementations for the Node-API runtime functions (linking to
napi_create_async_workin each case):shirakaba commentedon May 25, 2025
Where in the codebase are these to be implemented?
kraenhansen commentedon May 29, 2025
That's a great question - somewhere in the host package for sure: packages/react-native-node-api-modules/cpp their implementation likely needs to reach in to React Native APIs - perhaps even JSI? 🤔 (If the latter is the case, we might need a weak map to lookup the
jsi::Runtimebased onnapi_envtoo).I imagine we'll be implementing these functions, grouped by their Node-API version levels - we could
napi_envkraenhansen commentedon Aug 12, 2026
Status sweep against
nextAdopting Hermes' first-party Node-API (#372) and implementing
hermes_napi_host(#398) covered most of what this umbrella was tracking: the runtime-specific functions are now provided by Hermes'API/napi, with React Native supplying the pieces Hermes delegates to its embedder — a worker pool behindpost_work/cancel_work, the runtime'sCallInvokerbehindpost_taskand work completions, andfatal_exception. The buffer functions andnapi_fatal_errorremain host implementations inpackages/host/cpp/RuntimeNodeApi.cpp.Closed as completed (28) — each sub-issue has a comment pointing at what implements it:
hermes_napi_async_work.cpp+post_work/cancel_work(HermesNapiHost.cpp)hermes_napi_async_context.cpphermes_napi_tsfn.cpp+post_task(HermesNapiHost.cpp)hermes_napi.cppRuntimeNodeApi.cpp(Buffer asUint8Array)RuntimeNodeApi.cpp/fatal_exception(HermesNapiHost.cpp)hermes_napi.cpp— returnsnapi_generic_failure, no libuv loop by designTest coverage for the new surface:
packages/node-addon-examples/tests/async,.../tests/threadsafe-function(a port of Node'stest_threadsafe_function),.../tests/buffers(a port oftest_buffer), and the Catch2 suite inpackages/host/testsexercising the host contract on plain Linux.Still open (2):
napi_get_node_version#67napi_get_node_version— the host shim returnsnapi_generic_failureand shadows Hermes' working implementation in the generated injector. Policy call: drop the shim or keep the failure. Details in the issue.napi_module_register#70napi_module_register— Hermes records the module, but our loader never reads it back, so the deprecated registration path still fails to load an addon. Details in the issue.Two caveats recorded on the closed issues rather than left implicit: Buffer fidelity versus a real
Bufferis still #171 (the host'snapi_is_bufferis also looser than Node's), and tsfnref/unrefare tracked but inert since React Native has no loop lifetime to model (#82, #84).Generated by Claude Code