node/test/node-api
Gabriel Schulhof 7a216d5fd6
node-api: segregate nogc APIs from rest via type system
We define a new type called `node_api_nogc_env` as the `const` version
of `napi_env` and `node_api_nogc_finalize` as a variant of
`napi_finalize` that accepts a `node_api_nogc_env` as its first
argument.

We then modify those APIs which do not affect GC state as accepting a
`node_api_nogc_env`. APIs accepting finalizer callbacks are modified to
accept `node_api_nogc_finalize` callbacks. Thus, the only way to attach
a `napi_finalize` callback, wherein Node-APIs affecting GC state may be
called is to call `node_api_post_finalizer` from a
`node_api_nogc_finalize` callback.

In keeping with the process of introducing new Node-APIs, this feature
is guarded by `NAPI_EXPERIMENTAL`. Since this feature modifies APIs
already marked as stable, it is additionally guared by
`NODE_API_EXPERIMENTAL_NOGC_ENV`, so as to provide a further buffer to
adoption. Nevertheless, both guards must be removed upon releasing a
new version of Node-API.

PR-URL: https://github.com/nodejs/node/pull/50060
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2023-12-19 07:37:15 +00:00
..
1_hello_world
test_async test: fix assertion message in test_async.c 2023-08-15 11:55:34 +00:00
test_async_cleanup_hook node-api: verify cleanup hooks order 2023-03-15 00:57:25 +08:00
test_async_context test: add trailing commas in test/node-api 2023-01-29 20:01:09 +01:00
test_buffer node-api: enable uncaught exceptions policy by default 2023-09-25 04:23:58 +00:00
test_callback_scope test: add trailing commas in test/node-api 2023-01-29 20:01:09 +01:00
test_cleanup_hook node-api: verify cleanup hooks order 2023-03-15 00:57:25 +08:00
test_env_teardown_gc
test_exception
test_fatal src: print more information in C++ assertions 2023-11-01 16:20:18 +00:00
test_fatal_exception
test_general test: use tmpdir.resolve() 2023-08-21 16:41:53 +00:00
test_init_order
test_instance_data
test_make_callback
test_make_callback_recurse
test_null_init node-api: deprecate napi_module_register 2023-03-24 14:00:40 -04:00
test_policy test,benchmark: use tmpdir.fileURL() 2023-08-21 16:42:03 +00:00
test_reference_by_node_api_version node-api: segregate nogc APIs from rest via type system 2023-12-19 07:37:15 +00:00
test_threadsafe_function node-api: segregate nogc APIs from rest via type system 2023-12-19 07:37:15 +00:00
test_uv_loop
test_uv_threadpool_size test: improve UV_THREADPOOL_SIZE tests on .env 2023-11-03 17:25:54 +00:00
test_worker_buffer_callback src: throw DataCloneError on transfering untransferable objects 2023-05-05 11:22:42 +00:00
test_worker_terminate process,worker: ensure code after exit() effectless 2022-12-25 09:54:12 +00:00
test_worker_terminate_finalization
.gitignore
node-api.status
testcfg.py