-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why fs.promises.writeFile write buffer multi times with 512KiB limit for each time? #38309
Comments
Could you provide which code snippet in question? |
I think Node.js tries to write the whole buffer, but depending on the host OS/FS/hardware, it might need to write in several bits. How did you come with this
It certainly would be, but I'm afraid there's nothing we can do at Node.js level. |
The only place where I could find Lines 427 to 428 in a0261d2
If the file being read from is not a regular file (we can't tell the file size from statSync if it is not regular, stdin for instance), we create a buffer of size 8192 (value of the macro BUFSIZ of glibc) and read into it. We continue reading and appending the read buffer to an array of buffers while the number of bytes read (returned by tryReadSync ) is not 0.
|
node/lib/internal/fs/promises.js Line 298 in a0261d2
Sorry, I made a mistake while reading the source, in fact only Line 136 in a0261d2
|
The Note that prior to Node 15.12 the limit was |
Why not write the whole buffer one time?
Won't that be faster in fact?
The text was updated successfully, but these errors were encountered: