diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index 9487f48e841dbd..62a08a4b71704d 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -1,7 +1,5 @@ 'use strict'; -const kWriteFileMaxChunkSize = 2 ** 14; - const { ArrayPrototypePush, Error, @@ -40,6 +38,7 @@ const { kMaxUserId, kReadFileBufferLength, kReadFileUnknownBufferLength, + kWriteFileMaxChunkSize }, copyObject, getDirents, diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 1d4edc0e011e4c..4eb3386dff2d0b 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -125,6 +125,7 @@ const kIoMaxLength = 2 ** 31 - 1; // blocking other threads in case the available threads are all in use. const kReadFileUnknownBufferLength = 64 * 1024; const kReadFileBufferLength = 512 * 1024; +const kWriteFileMaxChunkSize = 512 * 1024; const kMaxUserId = 2 ** 32 - 1; @@ -835,6 +836,7 @@ module.exports = { kMaxUserId, kReadFileBufferLength, kReadFileUnknownBufferLength, + kWriteFileMaxChunkSize }, assertEncoding, BigIntStats, // for testing diff --git a/test/parallel/test-fs-promises-file-handle-writeFile.js b/test/parallel/test-fs-promises-file-handle-writeFile.js index 46c9019bc8d8dd..82074d341938b9 100644 --- a/test/parallel/test-fs-promises-file-handle-writeFile.js +++ b/test/parallel/test-fs-promises-file-handle-writeFile.js @@ -34,7 +34,7 @@ async function validateWriteFile() { async function doWriteAndCancel() { const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt'); const fileHandle = await open(filePathForHandle, 'w+'); - const buffer = Buffer.from('dogs running'.repeat(10000), 'utf8'); + const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8'); const controller = new AbortController(); const { signal } = controller; process.nextTick(() => controller.abort());