node/test/addons
Anna Henningsen 1723773d41
src: keep global list of addon-provided cleanup hooks
A recent change, 215027c8ed, introduced flakiness into our
test suite that exposed an issue with the cleanup hook API design.

Specifically, the signatures of `AddEnvironmentCleanupHook()` and
`RemoveEnvironmentCleanupHook()` are problematic. Both functions
take `Isolate*` arguments, as addons are not generally expected
to have to care about the Node.js `Environment` as a first-class
scope provider.

However, this model made the incorrect assumption that in the
situations in which `RemoveEnvironmentCleanupHook()` would be
invoked an `Environment` would always be associated with the
current `Isolate` (via the current V8 `Context`, if there is one).

This occasionally breaks down when `RemoveEnvironmentCleanupHook()`
is called during garbage collection -- which would be an expected
use case of the functionality, but one that has not been covered
through our tests before 215027c8ed.

Since Node.js guarantees API and ABI stability within a major version,
and this is a bug that is independent from the aforementioned change,
this commit resolves it by adding global mutable state to keep track
off cleanup hooks registered through the Node.js public API.

Obviously, this solution does not represent a desirable long-term
state, and a semver-minor follow up should add an API that does not
require modifications to these data structures, likely based on
the async cleanup hook API which already solves this issue properly.

Refs: https://github.com/nodejs/node/pull/63642
Fixes: https://github.com/nodejs/node/issues/63923
Signed-off-by: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/63985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-06-21 00:06:55 +02:00
..
async-cleanup-hook doc,src,test: replace use of deprecated GetIsolate 2025-10-04 18:48:35 +02:00
async-hello-world
async-hooks-id src: add ExecutionAsyncId getter for any Context 2025-04-17 18:00:05 +00:00
async-resource test: add type tags to uses of v8::External 2026-04-27 07:59:17 -03:00
buffer-free-callback
callback-scope test: enforce better never-settling-promise detection 2025-12-10 23:55:36 +00:00
cppgc-object test: prefer major GC in cppgc-object teardown 2025-11-24 16:20:18 +00:00
dlopen-ping-pong
errno-exception
esm deps: patch V8 to support compilation with MSVC 2025-05-02 15:10:33 +02:00
esm-export-default test,win: split addon tests 2025-10-04 18:48:46 +02:00
esm-export-primitive test,win: split addon tests 2025-10-04 18:48:46 +02:00
force-context-aware
heap-profiler doc,src,test: replace use of deprecated GetIsolate 2025-10-04 18:48:35 +02:00
hello-world test,win: split addon tests 2025-10-04 18:48:46 +02:00
hello-world-2 test,win: split addon tests 2025-10-04 18:48:46 +02:00
hello-world-function-export
load-long-path
make-callback src: update std::vector<v8::Local<T>> to use v8::LocalVector<T> 2025-05-31 18:58:07 +00:00
make-callback-domain-warning
make-callback-recurse test: ensure assertions are reachable in test/addons 2025-10-25 20:44:28 +02:00
new-context-inspector src: expose node::RegisterContext to make a node managed context 2026-05-23 00:05:39 +02:00
new-isolate-addon
new-target doc,src,test: replace use of deprecated GetIsolate 2025-10-04 18:48:35 +02:00
no-addons test: ensure assertions are reachable in test/addons 2025-10-25 20:44:28 +02:00
node-module-version
non-node-context test: fix typos 2024-09-28 13:58:55 +00:00
not-a-binding
null-buffer-neuter test: ensure assertions are reachable in test/addons 2025-10-25 20:44:28 +02:00
openssl-binding test: update test/addons/openssl-binding for OpenSSL 4.0 2026-05-05 16:19:32 +02:00
openssl-client-cert-engine deps: update OpenSSL build config to support compression 2026-06-20 16:58:11 +02:00
openssl-get-ssl-ctx test: update tls/crypto behaviour expectations when using BoringSSL 2026-05-19 21:38:38 +02:00
openssl-key-engine deps: update OpenSSL build config to support compression 2026-06-20 16:58:11 +02:00
openssl-providers test: forbid use of named imports for fixtures 2026-01-01 23:48:26 +00:00
openssl-test-engine deps: update OpenSSL build config to support compression 2026-06-20 16:58:11 +02:00
parse-encoding
register-signal-handler
repl-domain-abort test: fix addons and node-api test assumptions 2024-10-22 07:49:19 +00:00
report-api
report-fatalerror test: expand linting rules around assert w literal messages 2025-07-23 16:28:06 +00:00
request-interrupt
stringbytes-external-exceed-max
symlinked-module test: ensure assertions are reachable in test/addons 2025-10-25 20:44:28 +02:00
uv-handle-leak
uv-thread-name src: use node- prefix on thread names 2026-01-13 16:57:11 +00:00
worker-addon src: keep global list of addon-provided cleanup hooks 2026-06-21 00:06:55 +02:00
worker-addon-exit test: add regression test for using ObjectWrap in worker 2026-06-18 10:10:44 +02:00
worker-buffer-callback doc,src,test: replace use of deprecated GetIsolate 2025-10-04 18:48:35 +02:00
zlib-binding doc,src,test: replace use of deprecated GetIsolate 2025-10-04 18:48:35 +02:00
.gitignore esm: add experimental support for addon modules 2024-12-20 11:59:08 +00:00
addons.status crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts 2026-03-23 11:27:22 +00:00
common.gypi
testcfg.py