From 8dc86afbeeb0813cb57cd796293a258703fe856c Mon Sep 17 00:00:00 2001 From: mukunda katta Date: Fri, 15 May 2026 13:18:50 -0700 Subject: [PATCH] doc: clarify stream construct promise handling --- doc/api/stream.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index 5e30121673b7a1..e45b659da2dc74 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -3874,6 +3874,11 @@ has returned, delaying any `_write()`, `_final()` and `_destroy()` calls until `callback` is called. This is useful to initialize state or asynchronously initialize resources before the stream can be used. +If `_construct()` returns a promise, the promise fulfillment is equivalent to +calling `callback()` and promise rejection is equivalent to calling +`callback(err)`. A stream implementation must either call `callback` or return +a promise, not both. + ```js const { Writable } = require('node:stream'); const fs = require('node:fs'); @@ -4228,6 +4233,11 @@ constructor, delaying any `_read()` and `_destroy()` calls until `callback` is called. This is useful to initialize state or asynchronously initialize resources before the stream can be used. +If `_construct()` returns a promise, the promise fulfillment is equivalent to +calling `callback()` and promise rejection is equivalent to calling +`callback(err)`. A stream implementation must either call `callback` or return +a promise, not both. + ```js const { Readable } = require('node:stream'); const fs = require('node:fs');