nodejs / nodejs/node

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

Offen
#55,305 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

never-stale stream
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit den verknüpften Validierungspfaden in lib/internal/streams/pipeline.js, insbesondere mit der Behandlung von source, transform und destination rund um die Zeilen 306-308, 376 und 391-395. Vergleichen Sie die Parameternamensgebung von stream.compose() und sehen Sie sich die zugehörige Stream-Dokumentation an. Erledigt bedeutet, dass ungültige Argumente konsistent abgelehnt werden, Validierungsfehler den fehlerhaften Parameter identifizieren und die Unterstützung für TransformStream wie beschrieben dokumentiert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
backend, documentation
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.