MCPcopy Create free account
hub / github.com/nodejs/node / onDrain

Method onDrain

lib/internal/streams/fast-utf8-stream.js:699–721  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

697 #callFlushCallbackOnDrain(cb) {
698 this.#flushPending = true;
699 const onDrain = () => {
700 // Only if _fsync is false to avoid double fsync
701 if (!this.#fsync && !this.#destroyed) {
702 try {
703 this.#fs.fsync(this.#fd, (err) => {
704 this.#flushPending = false;
705 // If the fd is closed, we ignore the error.
706 if (err?.code === 'EBADF') {
707 cb();
708 return;
709 }
710 cb(err);
711 });
712 } catch (err) {
713 this.#flushPending = false;
714 cb(err);
715 }
716 } else {
717 this.#flushPending = false;
718 cb();
719 }
720 this.off('error', onError);
721 };
722 const onError = (err) => {
723 this.#flushPending = false;
724 cb(err);

Callers

nothing calls this directly

Calls 3

fsyncMethod · 0.80
cbFunction · 0.70
offMethod · 0.45

Tested by

no test coverage detected