Skip to content

Commit 5207099

Browse files
XeCyclejasnell
authored andcommitted
doc: clarify that fs streams expect blocking fd
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]>
1 parent c10c086 commit 5207099

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/api/fs.markdown

+4-1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ start at 0. The `encoding` can be any one of those accepted by [Buffer][].
307307

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

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

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

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

0 commit comments

Comments
 (0)