stream: handling invalid stream arguments in `stream.pipeline()`
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
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 asstreams[n], which would be a fairly straightforward improvement.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con i percorsi di validazione collegati in lib/internal/streams/pipeline.js, in particolare con la gestione di source, transform e destination nelle vicinanze delle righe 306-308, 376 e 391-395. Confronta i nomi dei parametri utilizzati da stream.compose() e consulta la documentazione correlata sugli stream. Il lavoro è completato quando gli argomenti non validi vengono rifiutati in modo coerente, gli errori di validazione identificano il parametro che causa il fallimento e il supporto per TransformStream è documentato come descritto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- backend, documentation
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100