MCPcopy Index your code
hub / github.com/nodejs/node / #actualClose

Method #actualClose

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

Source from the content-addressed store, hash-verified

535 }
536
537 #actualClose() {
538 if (this.#fd === -1) {
539 this.once('ready', () => this.#actualClose());
540 return;
541 }
542
543 if (this.#periodicFlushTimer !== undefined) {
544 clearInterval(this.#periodicFlushTimer);
545 }
546
547 this.#destroyed = true;
548 this.#bufs = [];
549 this.#lens = [];
550
551 const done = (err) => {
552 if (err) {
553 this.emit('error', err);
554 return;
555 }
556
557 if (this.#ending && !this.#writing) {
558 this.emit('finish');
559 }
560 this.emit('close');
561 };
562
563 const closeWrapped = () => {
564 // We skip errors in fsync
565 if (this.#fd !== 1 && this.#fd !== 2) {
566 this.#fs.close(this.#fd, done);
567 } else {
568 done();
569 }
570 };
571
572 try {
573 this.#fs.fsync(this.#fd, closeWrapped);
574 } catch {
575 // Intentionally empty.
576 }
577 }
578
579 #actualWriteBuffer() {
580 this.#writing = true;

Callers 3

endMethod · 0.95
destroyMethod · 0.95
#releaseMethod · 0.95

Calls 3

clearIntervalFunction · 0.85
fsyncMethod · 0.80
onceMethod · 0.45

Tested by

no test coverage detected