@@ -254,7 +254,6 @@ class ReadableStream {
254254 this [ kState ] = createReadableStreamState ( ) ;
255255
256256 this [ kIsClosedPromise ] = PromiseWithResolvers ( ) ;
257- this [ kControllerAbortFunction ] = ( ) => { } ;
258257
259258 // The spec requires handling of the strategy first
260259 // here. Specifically, if getting the size and
@@ -284,6 +283,20 @@ class ReadableStream {
284283 }
285284 }
286285
286+ [ kControllerAbortFunction ] ( error ) {
287+ if ( ! isReadableStream ( this ) )
288+ throw new ERR_INVALID_THIS ( 'ReadableStream' ) ;
289+
290+ const controller = this [ kState ] . controller ;
291+ if ( isReadableStreamDefaultController ( controller ) ) {
292+ readableStreamDefaultControllerError ( controller , error ) ;
293+ return ;
294+ }
295+
296+ assert ( isReadableByteStreamController ( controller ) ) ;
297+ readableByteStreamControllerError ( controller , error ) ;
298+ }
299+
287300 get [ kIsDisturbed ] ( ) {
288301 return this [ kState ] . disturbed ;
289302 }
@@ -2540,8 +2553,6 @@ function setupReadableStreamDefaultController(
25402553 stream,
25412554 } ;
25422555 stream [ kState ] . controller = controller ;
2543- stream [ kControllerAbortFunction ] =
2544- ( error ) => readableStreamDefaultControllerError ( controller , error ) ;
25452556
25462557 const startResult = startAlgorithm ( ) ;
25472558
@@ -3365,8 +3376,6 @@ function setupReadableByteStreamController(
33653376 pendingPullIntos : [ ] ,
33663377 } ;
33673378 stream [ kState ] . controller = controller ;
3368- stream [ kControllerAbortFunction ] =
3369- ( error ) => readableByteStreamControllerError ( controller , error ) ;
33703379
33713380 const startResult = startAlgorithm ( ) ;
33723381
0 commit comments