From 586ab5e7009ed25a2a0e3196571efde128311b59 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 1 Oct 2023 08:02:40 +0200 Subject: [PATCH] Disable FinalizationRegistry if NODE_V8_COVERAGE is set 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