Skip to content

Commit b74da91

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/abort_controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,9 +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;
201201
resultSignal[kSourceSignals] = new SafeSet();
202202
for (let i = 0; i < signals.length; i++) {
203+
resultSignalWeakRef ??= new WeakRef(resultSignal);
203204
const signal = signals[i];
204205
if (signal.aborted) {
205206
abortSignal(resultSignal, signal.reason);

0 commit comments

Comments
 (0)