Skip to content

Commit 1cea391

Browse files
authored
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 7d81994 commit 1cea391

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/api/deprecations.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,6 +3019,34 @@ should have the same effect. The receiving end should also check the
30193019
[`readable.readableEnded`][] value on [`http.IncomingMessage`][] to get whether
30203020
it was an aborted or graceful destroy.
30213021

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

0 commit comments

Comments
 (0)