Skip to content

Commit fc1e0ad

Browse files
committed
lib: use kResistStopPropagation
1 parent 0741f5a commit fc1e0ad

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/internal/abort_controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
kTrustEvent,
2424
kNewListener,
2525
kRemoveListener,
26+
kResistStopPropagation,
2627
kWeakHandler,
2728
} = require('internal/event_target');
2829
const {
@@ -435,7 +436,8 @@ async function aborted(signal, resource) {
435436
if (signal.aborted)
436437
return PromiseResolve();
437438
const abortPromise = createDeferredPromise();
438-
signal.addEventListener('abort', abortPromise.resolve, { [kWeakHandler]: resource, once: true });
439+
const opts = { __proto__: null, [kWeakHandler]: resource, once: true, [kResistStopPropagation]: true };
440+
signal.addEventListener('abort', abortPromise.resolve, opts);
439441
return abortPromise.promise;
440442
}
441443

lib/internal/watch_mode/files_watcher.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const { fileURLToPath } = require('url');
1818
const { resolve, dirname } = require('path');
1919
const { setTimeout } = require('timers');
2020

21+
let kResistStopPropagation;
2122

2223
const supportsRecursiveWatching = process.platform === 'win32' ||
2324
process.platform === 'darwin';
@@ -41,7 +42,11 @@ class FilesWatcher extends EventEmitter {
4142
this.#mode = mode;
4243
this.#signal = signal;
4344

44-
signal?.addEventListener('abort', () => this.clear(), { __proto__: null, once: true });
45+
if (signal) {
46+
kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation;
47+
const opts = { __proto__: null, once: true, [kResistStopPropagation]: true };
48+
signal?.addEventListener('abort', () => this.clear(), opts);
49+
}
4550
}
4651

4752
#isPathWatched(path) {

0 commit comments

Comments
 (0)