@@ -469,6 +469,77 @@ 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 signal = new EventTarget ( ) ;
525
+ signal . aborted = true ;
526
+ async function * producer ( ) {
527
+ yield '5' ;
528
+ await Promise . resolve ( ) ;
529
+ yield '8' ;
530
+ }
531
+
532
+ const w = new Writable ( {
533
+ write ( chunk , encoding , callback ) {
534
+ callback ( ) ;
535
+ }
536
+ } ) ;
537
+ await pipelinePromise ( producer , w , signal ) ;
538
+ }
539
+
540
+ assert . rejects ( run , { name : 'AbortError' } ) . then ( common . mustCall ( ) ) ;
541
+ }
542
+
472
543
{
473
544
const read = new Readable ( {
474
545
read ( ) { }
0 commit comments