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 <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
jazelly authored and targos committed Oct 2, 2024
1 parent 85542b0 commit d86f247
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 @@ -11,9 +11,9 @@ const {
PromiseResolve,
SafeFinalizationRegistry,
SafeSet,
SafeWeakRef,
Symbol,
SymbolToStringTag,
WeakRef,
} = primordials;

const {
Expand Down Expand Up @@ -188,7 +188,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 @@ -202,7 +202,7 @@ class AbortSignal extends EventTarget {
if (!signals.length) {
return resultSignal;
}
const resultSignalWeakRef = new WeakRef(resultSignal);
const resultSignalWeakRef = new SafeWeakRef(resultSignal);
resultSignal[kSourceSignals] = new SafeSet();
for (let i = 0; i < signals.length; i++) {
const signal = signals[i];
Expand All @@ -212,7 +212,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 d86f247

Please sign in to comment.