Skip to content

Commit

Permalink
doc: clarify that fs streams expect blocking fd
Browse files Browse the repository at this point in the history
This clarifies that fs.createReadStream and fs.createWriteStream, when
passed a fd, expects the fd to be blocking, and suggests net.Socket as
an alternative.

PR-URL: #3641
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
XeCycle authored and rvagg committed Dec 5, 2015
1 parent f29c5d6 commit f4ca007
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doc/api/fs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ start at 0. The `encoding` can be any one of those accepted by [Buffer][].

If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
the specified file descriptor. This means that no `open` event will be emitted.
Note that `fd` should be blocking; non-blocking `fd`s should be passed to
`net.Socket`.

If `autoClose` is false, then the file descriptor won't be closed, even if
there's an error. It is your responsibility to close it and make sure
Expand Down Expand Up @@ -341,7 +343,8 @@ default mode `w`. The `defaultEncoding` can be any one of those accepted by [Buf

Like `ReadStream` above, if `fd` is specified, `WriteStream` will ignore the
`path` argument and will use the specified file descriptor. This means that no
`open` event will be emitted.
`open` event will be emitted. Note that `fd` should be blocking; non-blocking
`fd`s should be passed to `net.Socket`.

If `options` is a string, then it specifies the encoding.

Expand Down

0 comments on commit f4ca007

Please sign in to comment.