Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: correct cleanup option in stream.(promises.)finished #55043

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@
- v18.14.0
pr-url: https://github.com/nodejs/node/pull/46205
description: Added support for `ReadableStream` and `WritableStream`.
- version:
- v19.1.0
- v18.13.0
pr-url: https://github.com/nodejs/node/pull/44862

Check warning on line 263 in doc/api/stream.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: The `cleanup` option was added.
-->

* `stream` {Stream|ReadableStream|WritableStream} A readable and/or writable
Expand All @@ -265,7 +270,9 @@
* `error` {boolean|undefined}
* `readable` {boolean|undefined}
* `writable` {boolean|undefined}
* `signal`: {AbortSignal|undefined}
* `signal` {AbortSignal|undefined}
* `cleanup` {boolean|undefined} If `true`, removes the listeners registered by
this function before the promise is fulfilled. **Default:** `false`.
Comment on lines 270 to +275
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that the convention for options parameter types is to include undefined?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO that's an issue for a different PR because this PR follows the same convention as the rest of the parameters.

* Returns: {Promise} Fulfills when the stream is no
longer readable or writable.

Expand Down Expand Up @@ -301,6 +308,17 @@

The `finished` API also provides a [callback version][stream-finished].

`stream.finished()` leaves dangling event listeners (in particular
`'error'`, `'end'`, `'finish'` and `'close'`) after the returned promise is
resolved or rejected. The reason for this is so that unexpected `'error'`
events (due to incorrect stream implementations) do not cause unexpected
crashes. If this is unwanted behavior then `options.cleanup` should be set to
`true`:

```js
await finished(rs, { cleanup: true });
```

### Object mode

All streams created by Node.js APIs operate exclusively on strings, {Buffer},
Expand Down Expand Up @@ -2754,8 +2772,6 @@
underlying stream will _not_ be aborted if the signal is aborted. The
callback will get called with an `AbortError`. All registered
listeners added by this function will also be removed.
* `cleanup` {boolean} remove all registered stream listeners.
**Default:** `false`.
* `callback` {Function} A callback function that takes an optional error
argument.
* Returns: {Function} A cleanup function which removes all registered
Expand Down
Loading