From 6cb4ad9f24b051013f7f0f533df507e24d45c4d4 Mon Sep 17 00:00:00 2001 From: atlowChemi Date: Tue, 13 Jun 2023 15:42:39 +0300 Subject: [PATCH] lib: create weakRef only if any signals provided --- lib/internal/abort_controller.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/abort_controller.js b/lib/internal/abort_controller.js index 779d2a7c39144a..e31738b98288ca 100644 --- a/lib/internal/abort_controller.js +++ b/lib/internal/abort_controller.js @@ -197,6 +197,9 @@ class AbortSignal extends EventTarget { static any(signals) { validateAbortSignalArray(signals, 'signals'); const resultSignal = createAbortSignal({ composite: true }); + if (!signals.length) { + return resultSignal; + } const resultSignalWeakRef = new WeakRef(resultSignal); resultSignal[kSourceSignals] = new SafeSet(); for (let i = 0; i < signals.length; i++) {