MCPcopy Index your code
hub / github.com/nodejs/node / cancel

Method cancel

lib/internal/streams/iter/share.js:225–255  ·  view source on GitHub ↗
(reason)

Source from the content-addressed store, hash-verified

223 }
224
225 cancel(reason) {
226 if (this.#cancelled) return;
227 this.#cancelled = true;
228
229 if (reason !== undefined) {
230 this.#sourceError = reason;
231 }
232
233 if (this.#sourceIterator?.return) {
234 PromisePrototypeThen(this.#sourceIterator.return(), undefined, () => {});
235 }
236
237 for (const consumer of this.#consumers) {
238 if (consumer.resolve) {
239 if (reason !== undefined) {
240 consumer.reject?.(reason);
241 } else {
242 consumer.resolve({ __proto__: null, done: true, value: undefined });
243 }
244 consumer.resolve = null;
245 consumer.reject = null;
246 }
247 consumer.detached = true;
248 }
249 this.#consumers.clear();
250
251 for (let i = 0; i < this.#pullWaiters.length; i++) {
252 this.#pullWaiters[i]();
253 }
254 this.#pullWaiters = [];
255 }
256
257 [SymbolDispose]() {
258 this.cancel();

Callers 2

[SymbolDispose]Method · 0.95
onShareCancelFunction · 0.45

Calls 4

rejectMethod · 0.80
clearMethod · 0.65
returnMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected