Skip to content

Commit fa9b5c3

Browse files
aduh95targos
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 3ec78d1 commit fa9b5c3

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
@@ -3017,6 +3017,34 @@ should have the same effect. The receiving end should also check the
30173017
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
30183018
it was an aborted or graceful destroy.
30193019

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

0 commit comments

Comments
 (0)