Skip to content

Commit f70772d

Browse files
committed
lib: create weakRef only if any signals provided
1 parent d402e2a commit f70772d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/internal/abort_controller.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ class AbortSignal extends EventTarget {
197197
static any(signals) {
198198
validateAbortSignalArray(signals, 'signals');
199199
const resultSignal = createAbortSignal({ composite: true });
200-
const resultSignalWeakRef = new WeakRef(resultSignal);
200+
let resultSignalWeakRef;
201+
if (signals.length) {
202+
resultSignalWeakRef ??= new WeakRef(resultSignal);
203+
}
201204
resultSignal[kSourceSignals] = new SafeSet();
202205
for (let i = 0; i < signals.length; i++) {
203206
const signal = signals[i];

0 commit comments

Comments
 (0)