`require('stream').promises` is an empty object when `stream/promises` is loaded before `stream`
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 58/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, node.js
Rechercherichtung
The issue identifies the cycle in lib/stream/promises.js and lib/stream.js; first read those files and inspect the lazy loading change in #66311. Add a regression test that loads stream/promises before stream and checks the expected shared exports, including the behavior described for util.promisify. Done when the test passes in both load orders.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version
v26.13.1, v24.22.3 and v22.23.5
Platform
Linux x64 and Windows x64 (official binaries)
Subsystem
stream
What steps will reproduce the bug?
$ node -e "require('stream/promises'); console.log(Object.keys(require('stream').promises))"
[]
With stream loaded first it is fine:
$ node -e "require('stream'); require('stream/promises'); console.log(Object.keys(require('stream').promises))"
[ 'finished', 'pipeline' ]
How often does it reproduce? Is there a required condition?
Always, when stream/promises is loaded before anything has loaded stream. ESM import
and the node: specifiers behave the same.
Anything that loads stream first hides it (console.log, net, http, ...), which is
probably why it has gone unnoticed. We hit it in an application whose entry point starts
with import { pipeline } from 'node:stream/promises' while a dependency calls
stream.promises.pipeline.
What is the expected behavior? Why is that the expected behavior?
require('stream').promises === require('stream/promises') in either load order.
What do you see instead?
require('stream').promises is a different, empty object for the life of the process, so
stream.promises.pipeline(...) throws TypeError: stream.promises.pipeline is not a function.
util.promisify(stream.pipeline) is affected too: it silently returns a generic wrapper
instead of the stream/promises function, and that wrapper rejects an options object
such as { signal }.
Additional information
Cause. stream and stream/promises require each other (line numbers from v24.22.3):
lib/stream/promises.js:17runsrequire('stream')before it setsmodule.exportslib/stream.js:51runsconst promises = require('stream/promises')and captures the
still-empty exports objectlib/stream/promises.js:41then replacesmodule.exports, whichstreamnever sees
It takes two changes together: #46147 added the require('stream') line, and #45659
stopped stream being loaded during bootstrap.
Status on main. #66311 ("worker: preload streams into startup snapshot") makes
lib/stream.js load stream/promises lazily, which removes the cycle. It is a worker
startup change: it does not mention this behavior and adds no test for it, and it is not
on the v22.x, v24.x or v26.x branches.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 124k
- Forks
- 38k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 266
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nodejs/node
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
Maintainer antworten meist innerhalb von 1 Tag
-
fs: document readStream.start and readStream.endEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offendoc
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
nodejs/node#67848 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
doc: document the Buffer.prototype.*Slice() methodsEvtl. vergeben @AyushCipher hat das heute übernommen. Offendoc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
nodejs/node#67847 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
`styleText` fast path bypasses `options` and `options.validateStream` validationEvtl. vergeben @GBra-4-669 hat das vor 8 Tagen übernommen. Offenutil
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
riscv64
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
nodejs/node#67655 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
bug triage needed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
[Resource]: PersephoneOffenresource-submission validation-passed
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
hesreallyhim/awesome-claude-code#3773 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the statusEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag