diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index d04e84aa9aa859..957e5b731981e5 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -4,6 +4,11 @@ // See https://github.com/libuv/libuv/pull/1501. const kIoMaxLength = 2 ** 31 - 1; +// Note: This is different from kReadFileBufferLength used for non-promisified +// fs.readFile. +const kReadFileMaxChunkSize = 2 ** 14; +const kWriteFileMaxChunkSize = 2 ** 14; + const { MathMax, MathMin, @@ -150,16 +155,12 @@ async function writeFileHandle(filehandle, data, options) { do { const { bytesWritten } = await write(filehandle, data, 0, - MathMin(16384, data.length)); + MathMin(kWriteFileMaxChunkSize, data.length)); remaining -= bytesWritten; data = data.slice(bytesWritten); } while (remaining > 0); } -// Note: This is different from kReadFileBufferLength used for non-promisified -// fs.readFile. -const kReadFileMaxChunkSize = 16384; - async function readFileHandle(filehandle, options) { const statFields = await binding.fstat(filehandle.fd, false, kUsePromises);