Skip to content

Commit 47ff44e

Browse files
committed
doc: add emitClose option for fs streams
PR-URL: #29212 Fixes: #29177 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent cb92126 commit 47ff44e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/api/fs.md

+16
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,9 @@ fs.copyFileSync('source.txt', 'destination.txt', COPYFILE_EXCL);
15041504
<!-- YAML
15051505
added: v0.1.31
15061506
changes:
1507+
- version: REPLACEME
1508+
pr-url: https://github.com/nodejs/node/pull/29212
1509+
description: Enable `emitClose` option.
15071510
- version: v11.0.0
15081511
pr-url: https://github.com/nodejs/node/pull/19898
15091512
description: Impose new restrictions on `start` and `end`, throwing
@@ -1529,6 +1532,7 @@ changes:
15291532
* `fd` {integer} **Default:** `null`
15301533
* `mode` {integer} **Default:** `0o666`
15311534
* `autoClose` {boolean} **Default:** `true`
1535+
* `emitClose` {boolean} **Default:** `false`
15321536
* `start` {integer}
15331537
* `end` {integer} **Default:** `Infinity`
15341538
* `highWaterMark` {integer} **Default:** `64 * 1024`
@@ -1555,6 +1559,10 @@ If `fd` points to a character device that only supports blocking reads
15551559
available. This can prevent the process from exiting and the stream from
15561560
closing naturally.
15571561

1562+
By default, the stream will not emit a `'close'` event after it has been
1563+
destroyed. This is the opposite of the default for other `Readable` streams.
1564+
Set the `emitClose` option to `true` to change this behavior.
1565+
15581566
```js
15591567
const fs = require('fs');
15601568
// Create a stream from some character device.
@@ -1592,6 +1600,9 @@ If `options` is a string, then it specifies the encoding.
15921600
<!-- YAML
15931601
added: v0.1.31
15941602
changes:
1603+
- version: REPLACEME
1604+
pr-url: https://github.com/nodejs/node/pull/29212
1605+
description: Enable `emitClose` option.
15951606
- version: v7.6.0
15961607
pr-url: https://github.com/nodejs/node/pull/10739
15971608
description: The `path` parameter can be a WHATWG `URL` object using
@@ -1615,6 +1626,7 @@ changes:
16151626
* `fd` {integer} **Default:** `null`
16161627
* `mode` {integer} **Default:** `0o666`
16171628
* `autoClose` {boolean} **Default:** `true`
1629+
* `emitClose` {boolean} **Default:** `false`
16181630
* `start` {integer}
16191631
* Returns: {fs.WriteStream} See [Writable Stream][].
16201632

@@ -1631,6 +1643,10 @@ then the file descriptor won't be closed, even if there's an error.
16311643
It is the application's responsibility to close it and make sure there's no
16321644
file descriptor leak.
16331645

1646+
By default, the stream will not emit a `'close'` event after it has been
1647+
destroyed. This is the opposite of the default for other `Writable` streams.
1648+
Set the `emitClose` option to `true` to change this behavior.
1649+
16341650
Like [`ReadStream`][], if `fd` is specified, [`WriteStream`][] will ignore the
16351651
`path` argument and will use the specified file descriptor. This means that no
16361652
`'open'` event will be emitted. `fd` should be blocking; non-blocking `fd`s

0 commit comments

Comments
 (0)