Skip to content

Commit 9dfd3b3

Browse files
committed
improve warning message for large file reads in fs.readFile()
1 parent c5be59a commit 9dfd3b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/fs/promises.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,9 @@ async function readFileHandle(filehandle, options) {
525525
size = statFields[8 /* size */];
526526

527527
if (size > kIoMaxLength) {
528+
const limit = kIoMaxLength;
528529
process.emitWarning(
529-
`Detected \`fs.readFile()\` to read a file larger than the recommended limit (${size} > ${limit} bytes). Please consider using \`fs.createReadStream()\` instead to minimize memory overhead and increase the performance.`,
530+
`Detected \`fs.readFile()\` to read a file larger than the recommended limit (${size} > ${limit} bytes). Please consider using \`fs.createReadStream()\` instead to minimize memory overhead and increase performance.`,
530531
'LargeFileWarning',
531532
ERR_FS_FILE_TOO_LARGE
532533
);

0 commit comments

Comments
 (0)