| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,6 +160,7 @@ let ReadStream; | |||
| 160 | 160 | let WriteStream; | |
| 161 | 161 | let rimraf; | |
| 162 | 162 | let rimrafSync; | |
| 163 | + let kResistStopPropagation; | ||
| 163 | 164 | ||
| 164 | 165 | // These have to be separate because of how graceful-fs happens to do it's | |
| 165 | 166 | // monkeypatching. | |
@@ -2435,7 +2436,8 @@ function watch(filename, options, listener) { | |||
| 2435 | 2436 | process.nextTick(() => watcher.close()); | |
| 2436 | 2437 | } else { | |
| 2437 | 2438 | const listener = () => watcher.close(); | |
| 2438 | - options.signal.addEventListener('abort', listener); | ||
| 2439 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 2440 | + options.signal.addEventListener('abort', listener, { __proto__: null, [kResistStopPropagation]: true }); | ||
| 2439 | 2441 | watcher.once('close', () => { | |
| 2440 | 2442 | options.signal.removeEventListener('abort', listener); | |
| 2441 | 2443 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,7 @@ function lazyLoadFsSync() { | |||
| 42 | 42 | internalSync ??= require('fs'); | |
| 43 | 43 | return internalSync; | |
| 44 | 44 | } | |
| 45 | + let kResistStopPropagation; | ||
| 45 | 46 | ||
| 46 | 47 | async function traverse(dir, files = new SafeMap(), symbolicLinks = new SafeSet()) { | |
| 47 | 48 | const { opendir } = lazyLoadFsPromises(); | |
@@ -265,7 +266,8 @@ class FSWatcher extends EventEmitter { | |||
| 265 | 266 | } : (resolve, reject) => { | |
| 266 | 267 | const onAbort = () => reject(new AbortError(undefined, { cause: signal.reason })); | |
| 267 | 268 | if (signal.aborted) return onAbort(); | |
| 268 | - signal.addEventListener('abort', onAbort, { __proto__: null, once: true }); | ||
| 269 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 270 | + signal.addEventListener('abort', onAbort, { __proto__: null, once: true, [kResistStopPropagation]: true }); | ||
| 269 | 271 | this.once('change', (eventType, filename) => { | |
| 270 | 272 | signal.removeEventListener('abort', onAbort); | |
| 271 | 273 | resolve({ __proto__: null, value: { eventType, filename } }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -299,6 +299,8 @@ ObjectDefineProperty(FSEvent.prototype, 'owner', { | |||
| 299 | 299 | set(v) { return this[owner_symbol] = v; }, | |
| 300 | 300 | }); | |
| 301 | 301 | ||
| 302 | + let kResistStopPropagation; | ||
| 303 | + | ||
| 302 | 304 | async function* watch(filename, options = kEmptyObject) { | |
| 303 | 305 | const path = toNamespacedPath(getValidatedPath(filename)); | |
| 304 | 306 | validateObject(options, 'options'); | |
@@ -330,7 +332,10 @@ async function* watch(filename, options = kEmptyObject) { | |||
| 330 | 332 | }; | |
| 331 | 333 | ||
| 332 | 334 | try { | |
| 333 | - signal?.addEventListener('abort', oncancel, { once: true }); | ||
| 335 | + if (signal) { | ||
| 336 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 337 | + signal.addEventListener('abort', oncancel, { __proto__: null, once: true, [kResistStopPropagation]: true }); | ||
| 338 | + } | ||
| 334 | 339 | handle.onchange = (status, eventType, filename) => { | |
| 335 | 340 | if (status < 0) { | |
| 336 | 341 | const error = uvException({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,8 @@ const nodeTimers = require('timers'); | |||
| 32 | 32 | const nodeTimersPromises = require('timers/promises'); | |
| 33 | 33 | const EventEmitter = require('events'); | |
| 34 | 34 | ||
| 35 | + let kResistStopPropagation; | ||
| 36 | + | ||
| 35 | 37 | function compareTimersLists(a, b) { | |
| 36 | 38 | return (a.runAt - b.runAt) || (a.id - b.id); | |
| 37 | 39 | } | |
@@ -100,17 +102,19 @@ class MockTimers { | |||
| 100 | 102 | if (options?.signal) { | |
| 101 | 103 | validateAbortSignal(options.signal, 'options.signal'); | |
| 102 | 104 | ||
| 103 | - if (options.signal?.aborted) { | ||
| 105 | + if (options.signal.aborted) { | ||
| 104 | 106 | throw abortIt(options.signal); | |
| 105 | 107 | } | |
| 106 | 108 | ||
| 107 | 109 | const onAbort = (reason) => { | |
| 108 | 110 | emitter.emit('data', { __proto__: null, aborted: true, reason }); | |
| 109 | 111 | }; | |
| 110 | 112 | ||
| 111 | - options.signal?.addEventListener('abort', onAbort, { | ||
| 113 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 114 | + options.signal.addEventListener('abort', onAbort, { | ||
| 112 | 115 | __proto__: null, | |
| 113 | 116 | once: true, | |
| 117 | + [kResistStopPropagation]: true, | ||
| 114 | 118 | }); | |
| 115 | 119 | } | |
| 116 | 120 | ||
@@ -161,7 +165,7 @@ class MockTimers { | |||
| 161 | 165 | return reject(err); | |
| 162 | 166 | } | |
| 163 | 167 | ||
| 164 | - if (options.signal?.aborted) { | ||
| 168 | + if (options.signal.aborted) { | ||
| 165 | 169 | return reject(abortIt(options.signal)); | |
| 166 | 170 | } | |
| 167 | 171 | } | |
@@ -175,10 +179,14 @@ class MockTimers { | |||
| 175 | 179 | return resolve(result || id); | |
| 176 | 180 | }, ms); | |
| 177 | 181 | ||
| 178 | - options?.signal?.addEventListener('abort', onabort, { | ||
| 179 | - __proto__: null, | ||
| 180 | - once: true, | ||
| 181 | - }); | ||
| 182 | + if (options?.signal) { | ||
| 183 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 184 | + options.signal.addEventListener('abort', onabort, { | ||
| 185 | + __proto__: null, | ||
| 186 | + once: true, | ||
| 187 | + [kResistStopPropagation]: true, | ||
| 188 | + }); | ||
| 189 | + } | ||
| 182 | 190 | }); | |
| 183 | 191 | } | |
| 184 | 192 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,8 @@ const kDiagnosticsFilterArgs = ['tests', 'suites', 'pass', 'fail', 'cancelled', | |||
| 76 | 76 | const kCanceledTests = new SafeSet() | |
| 77 | 77 | .add(kCancelledByParent).add(kAborted).add(kTestTimeoutFailure); | |
| 78 | 78 | ||
| 79 | + let kResistStopPropagation; | ||
| 80 | + | ||
| 79 | 81 | // TODO(cjihrig): Replace this with recursive readdir once it lands. | |
| 80 | 82 | function processPath(path, testFiles, options) { | |
| 81 | 83 | const stats = statSync(path); | |
@@ -441,7 +443,14 @@ function watchFiles(testFiles, root, inspectPort, signal, testNamePatterns) { | |||
| 441 | 443 | triggerUncaughtException(error, true /* fromPromise */); | |
| 442 | 444 | })); | |
| 443 | 445 | }); | |
| 444 | - signal?.addEventListener('abort', () => root.postRun(), { __proto__: null, once: true }); | ||
| 446 | + if (signal) { | ||
| 447 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 448 | + signal.addEventListener( | ||
| 449 | + 'abort', | ||
| 450 | + () => root.postRun(), | ||
| 451 | + { __proto__: null, once: true, [kResistStopPropagation]: true }, | ||
| 452 | + ); | ||
| 453 | + } | ||
| 445 | 454 | ||
| 446 | 455 | return filesWatcher; | |
| 447 | 456 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,7 @@ const kUnwrapErrors = new SafeSet() | |||
| 72 | 72 | .add(kTestCodeFailure).add(kHookFailure) | |
| 73 | 73 | .add('uncaughtException').add('unhandledRejection'); | |
| 74 | 74 | const { testNamePatterns, testOnlyFlag } = parseCommandLine(); | |
| 75 | + let kResistStopPropagation; | ||
| 75 | 76 | ||
| 76 | 77 | function stopTest(timeout, signal) { | |
| 77 | 78 | if (timeout === kDefaultTimeout) { | |
@@ -266,7 +267,15 @@ class Test extends AsyncResource { | |||
| 266 | 267 | this.signal = this.#abortController.signal; | |
| 267 | 268 | ||
| 268 | 269 | validateAbortSignal(signal, 'options.signal'); | |
| 269 | - this.#outerSignal?.addEventListener('abort', this.#abortHandler); | ||
| 270 | + if (signal) { | ||
| 271 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + this.#outerSignal?.addEventListener( | ||
| 275 | + 'abort', | ||
| 276 | + this.#abortHandler, | ||
| 277 | + { __proto__: null, [kResistStopPropagation]: true }, | ||
| 278 | + ); | ||
| 270 | 279 | ||
| 271 | 280 | this.fn = fn; | |
| 272 | 281 | this.harness = null; // Configured on the root test by the test harness. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ const { | |||
| 40 | 40 | } = require('internal/util'); | |
| 41 | 41 | ||
| 42 | 42 | const kScheduler = Symbol('kScheduler'); | |
| 43 | + let kResistStopPropagation; | ||
| 43 | 44 | ||
| 44 | 45 | function cancelListenerHandler(clear, reject, signal) { | |
| 45 | 46 | if (!this._destroyed) { | |
@@ -81,7 +82,8 @@ function setTimeout(after, value, options = kEmptyObject) { | |||
| 81 | 82 | if (signal) { | |
| 82 | 83 | oncancel = FunctionPrototypeBind(cancelListenerHandler, | |
| 83 | 84 | timeout, clearTimeout, reject, signal); | |
| 84 | - signal.addEventListener('abort', oncancel); | ||
| 85 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 86 | + signal.addEventListener('abort', oncancel, { __proto__: null, [kResistStopPropagation]: true }); | ||
| 85 | 87 | } | |
| 86 | 88 | }); | |
| 87 | 89 | return oncancel !== undefined ? | |
@@ -123,7 +125,8 @@ function setImmediate(value, options = kEmptyObject) { | |||
| 123 | 125 | oncancel = FunctionPrototypeBind(cancelListenerHandler, | |
| 124 | 126 | immediate, clearImmediate, reject, | |
| 125 | 127 | signal); | |
| 126 | - signal.addEventListener('abort', oncancel); | ||
| 128 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 129 | + signal.addEventListener('abort', oncancel, { __proto__: null, [kResistStopPropagation]: true }); | ||
| 127 | 130 | } | |
| 128 | 131 | }); | |
| 129 | 132 | return oncancel !== undefined ? | |
@@ -164,7 +167,8 @@ async function* setInterval(after, value, options = kEmptyObject) { | |||
| 164 | 167 | callback = undefined; | |
| 165 | 168 | } | |
| 166 | 169 | }; | |
| 167 | - signal.addEventListener('abort', onCancel, { once: true }); | ||
| 170 | + kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation; | ||
| 171 | + signal.addEventListener('abort', onCancel, { __proto__: null, once: true, [kResistStopPropagation]: true }); | ||
| 168 | 172 | } | |
| 169 | 173 | ||
| 170 | 174 | while (!signal?.aborted) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments