`require('stream').promises` is an empty object when `stream/promises` is loaded before `stream`
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 124k
- Forks
- 38k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 266
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nodejs/node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día
-
fs: document readStream.start and readStream.endPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertodoc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
nodejs/node#67848 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
doc: document the Buffer.prototype.*Slice() methodsPosiblemente ocupada @AyushCipher la tomó hoy. Abiertodoc
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
nodejs/node#67847 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
`styleText` fast path bypasses `options` and `options.validateStream` validationPosiblemente ocupada @GBra-4-669 la tomó hace 8 días. Abiertoutil
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
riscv64
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nodejs/node#67655 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de nodejs/node
Issues similares
-
bug triage needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
[Resource]: PersephoneAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
hesreallyhim/awesome-claude-code#3773 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 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 statusPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día