From 5f190b13c4004a10925fa8a27e495fbfc17dc291 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 1 Oct 2023 16:51:22 +0200 Subject: [PATCH] Disable FinalizationRegistry if NODE_V8_COVERAGE is set (#2298) Signed-off-by: Matteo Collina --- lib/compat/dispatcher-weakref.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/compat/dispatcher-weakref.js b/lib/compat/dispatcher-weakref.js index dbca8580404..db97e0f6e1e 100644 --- a/lib/compat/dispatcher-weakref.js +++ b/lib/compat/dispatcher-weakref.js @@ -31,6 +31,14 @@ class CompatFinalizer { } module.exports = function () { + // FIXME: remove workaround when the Node bug is fixed + // https://github.com/nodejs/node/issues/49344#issuecomment-1741776308 + if (process.env.NODE_V8_COVERAGE) { + return { + WeakRef: CompatWeakRef, + FinalizationRegistry: CompatFinalizer + } + } return { WeakRef: global.WeakRef || CompatWeakRef, FinalizationRegistry: global.FinalizationRegistry || CompatFinalizer