diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index e26f1314d155de..eab406f278ac35 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -1,5 +1,13 @@ 'use strict'; +// Most platforms don't allow reads or writes >= 2 GB. +// See https://github.com/libuv/libuv/pull/1501. +const kIoMaxLength = 2 ** 31 - 1; + +const kReadFileBufferLength = 512 * 1024; +const kReadFileUnknownBufferLength = 64 * 1024; +const kWriteFileMaxChunkSize = 512 * 1024; + const { ArrayPrototypePush, Error, diff --git a/test/parallel/test-fs-promises-file-handle-writeFile.js b/test/parallel/test-fs-promises-file-handle-writeFile.js index 44f049f55a9944..7ad1beb4bcdd7b 100644 --- a/test/parallel/test-fs-promises-file-handle-writeFile.js +++ b/test/parallel/test-fs-promises-file-handle-writeFile.js @@ -30,17 +30,13 @@ async function validateWriteFile() { async function doWriteAndCancel() { const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt'); const fileHandle = await open(filePathForHandle, 'w+'); - try { - const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8'); - const controller = new AbortController(); - const { signal } = controller; - process.nextTick(() => controller.abort()); - await assert.rejects(writeFile(fileHandle, buffer, { signal }), { - name: 'AbortError' - }); - } finally { - await fileHandle.close(); - } + const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8'); + const controller = new AbortController(); + const { signal } = controller; + process.nextTick(() => controller.abort()); + await assert.rejects(writeFile(fileHandle, buffer, { signal }), { + name: 'AbortError' + }); } validateWriteFile()