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

Function writevAll

lib/internal/fs/streams.js:441–468  ·  view source on GitHub ↗
(chunks, size, pos, cb, retries = 0)

Source from the content-addressed store, hash-verified

439}
440
441function writevAll(chunks, size, pos, cb, retries = 0) {
442 this[kFs].writev(this.fd, chunks, this.pos, (er, bytesWritten, buffers) => {
443 // No data currently available and operation should be retried later.
444 if (er?.code === 'EAGAIN') {
445 er = null;
446 bytesWritten = 0;
447 }
448
449 if (this.destroyed || er) {
450 return cb(er || new ERR_STREAM_DESTROYED('writev'));
451 }
452
453 this.bytesWritten += bytesWritten;
454
455 retries = bytesWritten ? 0 : retries + 1;
456 size -= bytesWritten;
457 pos += bytesWritten;
458
459 // Try writing non-zero number of bytes up to 5 times.
460 if (retries > 5) {
461 cb(new ERR_SYSTEM_ERROR('writev failed'));
462 } else if (size) {
463 writevAll.call(this, [Buffer.concat(buffers).slice(bytesWritten)], size, pos, cb, retries);
464 } else {
465 cb();
466 }
467 });
468}
469
470WriteStream.prototype._write = function(data, encoding, cb) {
471 this[kIsPerformingIO] = true;

Callers

nothing calls this directly

Calls 5

concatMethod · 0.80
sliceMethod · 0.65
cbFunction · 0.50
writevMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…