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 RafaelGSS committed Sep 16, 2024
1 parent 7b907cc commit 9840810
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 9840810

Please sign in to comment.