nodejs / nodejs/node

stream: handling invalid stream arguments in `stream.pipeline()`

Abierto
#55,305 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

never-stale stream
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

A few "what goes where"-related inconsistencies with stream.pipeline(). Validation of stream objects is very hit-and-miss:

Passing this: as this: should do this: and does this:
Non-readable Node stream source Should be rejected. :x: Passes validation. Gets passed to Duplex.from(), resulting in a write-only Duplex. The pipeline will never receive any data.
transform Should be rejected. :heavy_check_mark: Fails validation.
destination Should be accepted. :heavy_check_mark: Passes validation.
Non-writable Node stream source Should be accepted. :heavy_check_mark: Passes validation.
transform Should be rejected. :x: Passes validation. Fails asynchronously at runtime: when the previous stream in the pipeline emits data, raises a TypeError due to attempting to call missing Writable methods.
destination Should be rejected. :x: Same as above.
ReadableStream source Should be accepted. :heavy_check_mark: Passes validation.
transform Should be rejected. :heavy_check_mark: Fails validation.
destination Should be rejected. :x: Passes validation. Fails asynchronously at runtime: raises a TypeError due to attempting to call the missing getWriter() method.
TransformStream source Undocumented, but should be accepted. :heavy_check_mark: Passes validation.
transform Should be accepted. :heavy_check_mark: Passes validation.
destination Undocumented, but should be accepted. :heavy_check_mark: Passes validation.
WritableStream source Should be rejected. :x: Passes validation. Gets passed to Duplex.from(), resulting in a write-only Duplex. The pipeline will never receive any data.
transform Should be rejected. :heavy_check_mark: Fails validation.
destination Should be accepted. :heavy_check_mark: Passes validation.

These should probably be validated consistently.

Other observations:

  • The docs should specify that TransformStreams are valid source and destination streams, as well as valid return values.
  • The transform validation error message doesn't specify which parameter failed validation, which is a pain in terms of debugging. Its counterparts in stream.compose() pass the parameter name to the error constructor as streams[n], which would be a fairly straightforward improvement.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con las rutas de validación enlazadas en lib/internal/streams/pipeline.js, especialmente con el manejo de source, transform y destination alrededor de las líneas 306-308, 376 y 391-395. Compara los nombres de los parámetros utilizados por stream.compose() y revisa la documentación relacionada de streams. Se considera terminado cuando los argumentos no válidos se rechazan de forma coherente, los errores de validación identifican el parámetro que falla y la compatibilidad con TransformStream está documentada como se describe.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
backend, documentation
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.