Skip to content

Commit 8dc86af

Browse files
committed
doc: clarify stream construct promise handling
1 parent e568673 commit 8dc86af

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

doc/api/stream.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,6 +3874,11 @@ has returned, delaying any `_write()`, `_final()` and `_destroy()` calls until
38743874
`callback` is called. This is useful to initialize state or asynchronously
38753875
initialize resources before the stream can be used.
38763876

3877+
If `_construct()` returns a promise, the promise fulfillment is equivalent to
3878+
calling `callback()` and promise rejection is equivalent to calling
3879+
`callback(err)`. A stream implementation must either call `callback` or return
3880+
a promise, not both.
3881+
38773882
```js
38783883
const { Writable } = require('node:stream');
38793884
const fs = require('node:fs');
@@ -4228,6 +4233,11 @@ constructor, delaying any `_read()` and `_destroy()` calls until `callback` is
42284233
called. This is useful to initialize state or asynchronously initialize
42294234
resources before the stream can be used.
42304235
4236+
If `_construct()` returns a promise, the promise fulfillment is equivalent to
4237+
calling `callback()` and promise rejection is equivalent to calling
4238+
`callback(err)`. A stream implementation must either call `callback` or return
4239+
a promise, not both.
4240+
42314241
```js
42324242
const { Readable } = require('node:stream');
42334243
const fs = require('node:fs');

0 commit comments

Comments
 (0)