@@ -469,6 +469,78 @@ const net = require('net');
469
469
run ( ) ;
470
470
}
471
471
472
+ {
473
+ // Check aborted signal without values
474
+ const pipelinePromise = promisify ( pipeline ) ;
475
+ async function run ( ) {
476
+ const ac = new AbortController ( ) ;
477
+ const { signal } = ac ;
478
+ async function * producer ( ) {
479
+ ac . abort ( ) ;
480
+ await Promise . resolve ( ) ;
481
+ yield '8' ;
482
+ }
483
+
484
+ const w = new Writable ( {
485
+ write ( chunk , encoding , callback ) {
486
+ callback ( ) ;
487
+ }
488
+ } ) ;
489
+ await pipelinePromise ( producer , w , signal ) ;
490
+ }
491
+
492
+ assert . rejects ( run , { name : 'AbortError' } ) . then ( common . mustCall ( ) ) ;
493
+ }
494
+
495
+ {
496
+ // Check aborted signal after init.
497
+ const pipelinePromise = promisify ( pipeline ) ;
498
+ async function run ( ) {
499
+ const ac = new AbortController ( ) ;
500
+ const { signal } = ac ;
501
+ async function * producer ( ) {
502
+ yield '5' ;
503
+ await Promise . resolve ( ) ;
504
+ ac . abort ( ) ;
505
+ await Promise . resolve ( ) ;
506
+ yield '8' ;
507
+ }
508
+
509
+ const w = new Writable ( {
510
+ write ( chunk , encoding , callback ) {
511
+ callback ( ) ;
512
+ }
513
+ } ) ;
514
+ await pipelinePromise ( producer , w , signal ) ;
515
+ }
516
+
517
+ assert . rejects ( run , { name : 'AbortError' } ) . then ( common . mustCall ( ) ) ;
518
+ }
519
+
520
+ {
521
+ // Check pre-aborted signal
522
+ const pipelinePromise = promisify ( pipeline ) ;
523
+ async function run ( ) {
524
+ const ac = new AbortController ( ) ;
525
+ const { signal } = ac ;
526
+ ac . abort ( ) ;
527
+ async function * producer ( ) {
528
+ yield '5' ;
529
+ await Promise . resolve ( ) ;
530
+ yield '8' ;
531
+ }
532
+
533
+ const w = new Writable ( {
534
+ write ( chunk , encoding , callback ) {
535
+ callback ( ) ;
536
+ }
537
+ } ) ;
538
+ await pipelinePromise ( producer , w , signal ) ;
539
+ }
540
+
541
+ assert . rejects ( run , { name : 'AbortError' } ) . then ( common . mustCall ( ) ) ;
542
+ }
543
+
472
544
{
473
545
const read = new Readable ( {
474
546
read ( ) { }
0 commit comments