Skip to content

Commit

Permalink
lib: make WeakRef safe in abort_controller
Browse files Browse the repository at this point in the history
PR-URL: #54791
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
jazelly authored and jasnell committed Sep 13, 2024
1 parent d38dc99 commit fee02c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/internal/abort_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const {
PromiseResolve,
SafeFinalizationRegistry,
SafeSet,
SafeWeakRef,
Symbol,
SymbolToStringTag,
WeakRef,
} = primordials;

const {
Expand Down Expand Up @@ -220,7 +220,7 @@ class AbortSignal extends EventTarget {
signal[kTimeout] = true;
clearTimeoutRegistry.register(
signal,
setWeakAbortSignalTimeout(new WeakRef(signal), delay));
setWeakAbortSignalTimeout(new SafeWeakRef(signal), delay));
return signal;
}

Expand All @@ -238,7 +238,7 @@ class AbortSignal extends EventTarget {
if (!signalsArray.length) {
return resultSignal;
}
const resultSignalWeakRef = new WeakRef(resultSignal);
const resultSignalWeakRef = new SafeWeakRef(resultSignal);
resultSignal[kSourceSignals] = new SafeSet();
for (let i = 0; i < signalsArray.length; i++) {
const signal = signalsArray[i];
Expand All @@ -248,7 +248,7 @@ class AbortSignal extends EventTarget {
}
signal[kDependantSignals] ??= new SafeSet();
if (!signal[kComposite]) {
resultSignal[kSourceSignals].add(new WeakRef(signal));
resultSignal[kSourceSignals].add(new SafeWeakRef(signal));
signal[kDependantSignals].add(resultSignalWeakRef);
} else if (!signal[kSourceSignals]) {
continue;
Expand Down

0 comments on commit fee02c7

Please sign in to comment.