Skip to content

Commit 60d7cf3

Browse files
committed
fixes
1 parent 0c3382e commit 60d7cf3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/internal/fs/streams.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
ERR_INVALID_ARG_TYPE,
1616
ERR_OUT_OF_RANGE,
1717
ERR_METHOD_NOT_IMPLEMENTED,
18+
ERR_SYSTEM_ERROR,
1819
} = require('internal/errors').codes;
1920
const {
2021
deprecate,
@@ -409,8 +410,9 @@ function writeAll(data, size, pos, cb, retries = 0) {
409410
size -= bytesWritten;
410411
pos += bytesWritten;
411412

413+
// Try writing non-zero number of bytes up to 5 times.
412414
if (retries > 5) {
413-
cb(new Error('writev failed'));
415+
cb(new ERR_SYSTEM_ERROR('write failed'));
414416
} else if (size) {
415417
writeAll(buffer.slice(bytesWritten), size, pos, cb, retries);
416418
} else {
@@ -436,8 +438,9 @@ function writevAll(chunks, size, pos, cb, retries = 0) {
436438
size -= bytesWritten;
437439
pos += bytesWritten;
438440

441+
// Try writing non-zero number of bytes up to 5 times.
439442
if (retries > 5) {
440-
cb(new Error('writev failed'));
443+
cb(new ERR_SYSTEM_ERROR('writev failed'));
441444
} else if (size) {
442445
writevAll([Buffer.concat(buffers).slice(bytesWritten)], size, pos, cb, retries);
443446
} else {
@@ -448,7 +451,7 @@ function writevAll(chunks, size, pos, cb, retries = 0) {
448451

449452
WriteStream.prototype._write = function(data, encoding, cb) {
450453
this[kIsPerformingIO] = true;
451-
writeAll.call(this, data.length, data, this.pos, (er) => {
454+
writeAll.call(this, data, data.length, this.pos, (er) => {
452455
this[kIsPerformingIO] = false;
453456
if (this.destroyed) {
454457
// Tell ._destroy() that it's safe to close the fd now.
@@ -476,7 +479,7 @@ WriteStream.prototype._writev = function(data, cb) {
476479
}
477480

478481
this[kIsPerformingIO] = true;
479-
writevAll.call(this, size, chunks, this.pos, (er) => {
482+
writevAll.call(this, chunks, size, this.pos, (er) => {
480483
this[kIsPerformingIO] = false;
481484
if (this.destroyed) {
482485
// Tell ._destroy() that it's safe to close the fd now.

0 commit comments

Comments
 (0)