Skip to content

Commit

Permalink
lib: create weakRef only if any signals provided
Browse files Browse the repository at this point in the history
  • Loading branch information
atlowChemi committed Jun 13, 2023
1 parent d402e2a commit f70772d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/internal/abort_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ class AbortSignal extends EventTarget {
static any(signals) {
validateAbortSignalArray(signals, 'signals');
const resultSignal = createAbortSignal({ composite: true });
const resultSignalWeakRef = new WeakRef(resultSignal);
let resultSignalWeakRef;
if (signals.length) {
resultSignalWeakRef ??= new WeakRef(resultSignal);
}
resultSignal[kSourceSignals] = new SafeSet();
for (let i = 0; i < signals.length; i++) {
const signal = signals[i];
Expand Down

0 comments on commit f70772d

Please sign in to comment.