From 3a9f48171d7486a558ac6f62a7c521d46fdd208b Mon Sep 17 00:00:00 2001 From: Khafra Date: Wed, 11 Oct 2023 02:30:04 -0400 Subject: [PATCH] fix fetch with coverage enabled (#2330) --- lib/compat/dispatcher-weakref.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/compat/dispatcher-weakref.js b/lib/compat/dispatcher-weakref.js index db97e0f6e1e..8cb99e21501 100644 --- a/lib/compat/dispatcher-weakref.js +++ b/lib/compat/dispatcher-weakref.js @@ -22,11 +22,13 @@ class CompatFinalizer { } register (dispatcher, key) { - dispatcher.on('disconnect', () => { - if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) { - this.finalizer(key) - } - }) + if (dispatcher.on) { + dispatcher.on('disconnect', () => { + if (dispatcher[kConnected] === 0 && dispatcher[kSize] === 0) { + this.finalizer(key) + } + }) + } } }