nodejs / nodejs/node

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

Đang mở
#55,305 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

never-stale stream
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các đường dẫn xác thực được liên kết trong lib/internal/streams/pipeline.js, đặc biệt là phần xử lý source, transform và destination quanh các dòng 306-308, 376 và 391-395. So sánh cách đặt tên tham số được stream.compose() sử dụng và kiểm tra tài liệu stream liên quan. Được xem là hoàn tất khi các đối số không hợp lệ bị từ chối nhất quán, lỗi xác thực xác định tham số gây lỗi và việc hỗ trợ TransformStream được ghi lại như mô tả.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
backend, documentation
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.