Commit 32eaae7
committed
stream: use Writer try-fallback pattern in pipeTo and Broadcast.from
The `Writer` interface sync methods are designed as try-fallback
pairs: attempt the fast sync path first, fall back to async only
when rejected or unavailable. This was not being followed in
`pipeTo`, `pipeToSync`, or `Broadcast.from()`.
`pipeTo` now attempts `writeSync`/`writevSync` before `write`/`writev`,
`endSync` before `end`, and `failSync` before `fail`, with graceful
handling when *Sync methods are not present on the writer.
`pipeToSync` similarly prefers *Sync methods with fallback to
the non-sync variants for writers that lack them.
`Broadcast.from()` applies the same pattern when writing source
data to the internal broadcast writer.
Additionally, writes in p`ipeTo are now sequential rather than
parallel (previously used `Promise.all`), which respects writer
backpressure signals.1 parent 0c9827a commit 32eaae7
2 files changed
+56
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| 686 | + | |
686 | 687 | | |
687 | 688 | | |
688 | 689 | | |
| |||
691 | 692 | | |
692 | 693 | | |
693 | 694 | | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
699 | 700 | | |
700 | 701 | | |
701 | 702 | | |
| |||
705 | 706 | | |
706 | 707 | | |
707 | 708 | | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
713 | 714 | | |
714 | 715 | | |
715 | 716 | | |
716 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
717 | 720 | | |
718 | | - | |
719 | | - | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
720 | 726 | | |
721 | 727 | | |
722 | 728 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
610 | 609 | | |
611 | 610 | | |
612 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
613 | 615 | | |
614 | 616 | | |
615 | 617 | | |
616 | 618 | | |
617 | 619 | | |
618 | | - | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
619 | 623 | | |
620 | 624 | | |
621 | 625 | | |
622 | 626 | | |
623 | 627 | | |
624 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
625 | 631 | | |
626 | 632 | | |
627 | 633 | | |
628 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
629 | 639 | | |
630 | 640 | | |
631 | 641 | | |
| |||
657 | 667 | | |
658 | 668 | | |
659 | 669 | | |
| 670 | + | |
| 671 | + | |
660 | 672 | | |
661 | | - | |
| 673 | + | |
| 674 | + | |
662 | 675 | | |
663 | 676 | | |
664 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
665 | 681 | | |
666 | 682 | | |
667 | 683 | | |
668 | 684 | | |
669 | | - | |
670 | 685 | | |
671 | 686 | | |
672 | | - | |
673 | | - | |
674 | | - | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
675 | 692 | | |
676 | 693 | | |
677 | 694 | | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | 695 | | |
682 | 696 | | |
683 | 697 | | |
| |||
719 | 733 | | |
720 | 734 | | |
721 | 735 | | |
722 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
723 | 740 | | |
724 | 741 | | |
725 | 742 | | |
726 | | - | |
727 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
728 | 749 | | |
729 | 750 | | |
730 | 751 | | |
| |||
0 commit comments