Affected URL(s)
https://nodejs.org/api/fs.html#fsreadfd-buffer-offset-length-position-callback
Description of the problem
It is not clear from Node's fs.read() docs, whether the length argument indicates the maximum number of bytes that Node will attempt to read from the kernel, or whether Node will return exactly length bytes (possibly making multiple read syscalls in the process).
Ie: if I call fs.read() with length = 10, which of these holds:
- When reading a file that is 9 bytes long, exactly 9 bytes are read and
bytesRead is set to 9.
- When reading a file that is 9 bytes long, the callback is called with an error because EOF was encountered before the buffer could be filled.
- When reading a file that is 11 bytes long, exactly 10 bytes are read and
bytesRead is set to 10.
- When reading a file that is 11 bytes long, but the file is on a slow network filesystem that only reads in chunks of 5 bytes per second, 5 bytes are read and
bytesRead is set to 5.
This is an important thing to document because it determines whether you need to wrap the read call in a loop (like the Linux syscall) if you need a minimum amount of bytes, or whether you do not have to do this.
Affected URL(s)
https://nodejs.org/api/fs.html#fsreadfd-buffer-offset-length-position-callback
Description of the problem
It is not clear from Node's
fs.read()docs, whether thelengthargument indicates the maximum number of bytes that Node will attempt to read from the kernel, or whether Node will return exactlylengthbytes (possibly making multiplereadsyscalls in the process).Ie: if I call
fs.read()with length = 10, which of these holds:bytesReadis set to 9.bytesReadis set to 10.bytesReadis set to 5.This is an important thing to document because it determines whether you need to wrap the
readcall in a loop (like the Linux syscall) if you need a minimum amount of bytes, or whether you do not have to do this.