Skip to content

Commit 4af8f70

Browse files
aduh95danielleadams
authored andcommitted
stream: deprecate thenable support
Deprecate support for returning thenables in stream implementation methods. This is causing more confusion and issues than it's worth, and never was documented. Refs: #39535 Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: #40860 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4c5fcc2 commit 4af8f70

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/api/deprecations.md

+28
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,34 @@ should have the same effect. The receiving end should also check the
30043004
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
30053005
it was an aborted or graceful destroy.
30063006

3007+
### DEP0157: Thenable support in streams
3008+
3009+
<!-- YAML
3010+
changes:
3011+
- version: REPLACEME
3012+
pr-url: https://github.com/nodejs/node/pull/40860
3013+
description: Documentation-only deprecation.
3014+
-->
3015+
3016+
Type: Documentation-only
3017+
3018+
An undocumented feature of Node.js streams was to support thenables in
3019+
implementation methods. This is now deprecated, use callbacks instead and avoid
3020+
use of async function for streams implementation methods.
3021+
3022+
This feature caused users to encounter unexpected problems where the user
3023+
implements the function in callback style but uses e.g. an async method which
3024+
would cause an error since mixing promise and callback semantics is not valid.
3025+
3026+
```js
3027+
const w = new Writable({
3028+
async final(callback) {
3029+
await someOp();
3030+
callback();
3031+
}
3032+
});
3033+
```
3034+
30073035
[Legacy URL API]: url.md#legacy-url-api
30083036
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
30093037
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3

0 commit comments

Comments
 (0)