@@ -14,6 +14,7 @@ const {
1414 arrayBufferSync,
1515 array,
1616 arraySync,
17+ toAsyncStreamable,
1718} = require ( 'stream/iter' ) ;
1819
1920// =============================================================================
@@ -75,6 +76,31 @@ async function testAsyncConsumersAbortPendingNext() {
7576 }
7677}
7778
79+ async function testAsyncConsumersAbortPendingNormalization ( ) {
80+ const consumers = [
81+ [ 'bytes' , bytes ] ,
82+ [ 'text' , text ] ,
83+ [ 'arrayBuffer' , arrayBuffer ] ,
84+ [ 'array' , array ] ,
85+ ] ;
86+
87+ for ( const [ name , consumer ] of consumers ) {
88+ const ac = new AbortController ( ) ;
89+ const reason = new Error ( `${ name } normalization boom` ) ;
90+ const source = {
91+ __proto__ : null ,
92+ [ toAsyncStreamable ] ( ) {
93+ return new Promise ( ( ) => { } ) ;
94+ } ,
95+ } ;
96+
97+ const promise = consumer ( source , { __proto__ : null , signal : ac . signal } ) ;
98+ ac . abort ( reason ) ;
99+
100+ await assert . rejects ( promise , reason ) ;
101+ }
102+ }
103+
78104async function testBytesEmpty ( ) {
79105 const data = await bytes ( from ( [ ] ) ) ;
80106 assert . ok ( data instanceof Uint8Array ) ;
@@ -228,6 +254,7 @@ Promise.all([
228254 testBytesAsyncLimit ( ) ,
229255 testBytesAsyncAbort ( ) ,
230256 testAsyncConsumersAbortPendingNext ( ) ,
257+ testAsyncConsumersAbortPendingNormalization ( ) ,
231258 testBytesEmpty ( ) ,
232259 testArrayBufferSyncBasic ( ) ,
233260 testArrayBufferAsync ( ) ,
0 commit comments