-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
What does fs.read's length argument indicate? #52447
Copy link
Copy link
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
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.