Add initial Node-API (N-API) PoC scaffolding - #1606
Merged
Merged
Conversation
ksh8281
force-pushed
the
napi
branch
10 times, most recently
from
August 7, 2026 07:16
76c5f90 to
2cb7773
Compare
…ld stability This commit implements the complete N-API (Node-API) C-ABI standard layers for Escargot and provides extensive test coverage and real-world addon verification, with absolutely zero documentation markdown files in the history. 1. Foundational N-API & Handle Scope Infrastructure: - Established the core napi_env context and full handle scope lifecycles (napi_handle_scope, napi_escapable_handle_scope, napi_escape_handle). - Wired strict parameter NULL validation guards (CHECK_ENV/CHECK_ARG) globally across all napi_* public entry points. 2. Object Wrapping & Reference Lifetime Engine: - Implemented napi_define_class, napi_wrap, and napi_unwrap to support C++ class instance bindings to JavaScript heap objects. - Built a complete reference counting system (napi_ref) to support strong, weak, and stale-reference finalization lifecycle hooks. 3. Libuv Multithreading, AsyncWork, and TSFN Integration: - Wired libuv's async loop and worker thread pool to implement napi_queue_async_work and napi_threadsafe_function (TSFN). - Fully actualized TSFN refcounting (napi_ref_threadsafe_function/napi_unref_threadsafe_function) directly via uv_ref and uv_unref on the underlying uv_async_t handle. - Added a synchronous 'uvLoopAlive()' drain barrier right before NapiEnv teardown to eliminate the thread-pool shutdown SIGSEGV race in ThreadLocal::finalize. 4. Event Pump & nextTick Priority Queue (Harness Upgrade): - Overhauled the NapiSuite harness to support true OS-level sleep waiting via genuine uv_timer_t timers and uv_run(UV_RUN_ONCE), completely eradicating busy-wait CPU spinning. - Implemented a dedicated high-fidelity process.nextTick priority queue in harness.js and nested scope-depth-gated queue draining in napi_make_callback, successfully passing NodeApiMakeCallbackRecurse. 5. Real-world Verification: - Successfully proved complete binary-level ABI stability by executing unmodified sqlite3 and bcrypt binaries inside our cctest --napi-run sandbox, completing both complex DB CRUD and multi-threaded cryptography workflows. Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
bwikbs
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vendor node-api-headers and a sparse nodejs/node test corpus, implement enough js_native_api.h to pass test/js-native-api/2_function_arguments.