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

Method fail

lib/internal/streams/iter/push.js:321–344  ·  view source on GitHub ↗

* Put queue into terminal error state. * No-op if errored or closed (fully drained). * If closing (draining), short-circuits the drain.

(reason = kNoFailReason)

Source from the content-addressed store, hash-verified

319 * If closing (draining), short-circuits the drain.
320 */
321 fail(reason = kNoFailReason) {
322 if (this.#writerState === 'errored' || this.#writerState === 'closed') {
323 return;
324 }
325
326 const wasClosing = this.#writerState === 'closing';
327 this.#writerState = 'errored';
328 this.#error = reason === kNoFailReason ?
329 new ERR_INVALID_STATE('Failed') :
330 reason;
331 this.#cleanup();
332 this.#rejectPendingReads(this.#error);
333 this.#rejectPendingDrains(this.#error);
334
335 if (wasClosing) {
336 // Short-circuit the graceful drain: reject the pending end promise
337 if (this.#pendingEnd) {
338 this.#pendingEnd.reject(this.#error);
339 this.#pendingEnd = null;
340 }
341 } else {
342 this.#rejectPendingWrites(this.#error);
343 }
344 }
345
346 get totalBytesWritten() {
347 return this.#bytesWritten;

Callers 6

constructorMethod · 0.95
_destroyFunction · 0.45
abortBothFunction · 0.45
pipeToSyncFunction · 0.45
pipeToFunction · 0.45
failMethod · 0.45

Calls 5

#cleanupMethod · 0.95
#rejectPendingReadsMethod · 0.95
#rejectPendingDrainsMethod · 0.95
#rejectPendingWritesMethod · 0.95
rejectMethod · 0.80

Tested by

no test coverage detected