@@ -27,6 +27,7 @@ Object.assign(exports, {
2727 WritableStreamDefaultControllerClearAlgorithms,
2828 WritableStreamDefaultControllerError,
2929 WritableStreamDefaultControllerErrorIfNeeded,
30+ WritableStreamDefaultControllerReleaseBackpressure,
3031 WritableStreamDefaultWriterAbort,
3132 WritableStreamDefaultWriterClose,
3233 WritableStreamDefaultWriterCloseWithErrorPropagation,
@@ -543,6 +544,7 @@ function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm
543544
544545 controller . _abortController = new AbortController ( ) ;
545546 controller . _started = false ;
547+ controller . _releaseBackpressure = false ;
546548
547549 controller . _strategySizeAlgorithm = sizeAlgorithm ;
548550 controller . _strategyHWM = highWaterMark ;
@@ -657,6 +659,9 @@ function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
657659}
658660
659661function WritableStreamDefaultControllerGetBackpressure ( controller ) {
662+ if ( controller . _releaseBackpressure === true ) {
663+ return false ;
664+ }
660665 const desiredSize = WritableStreamDefaultControllerGetDesiredSize ( controller ) ;
661666 return desiredSize <= 0 ;
662667}
@@ -727,6 +732,19 @@ function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
727732 ) ;
728733}
729734
735+ function WritableStreamDefaultControllerReleaseBackpressure ( controller ) {
736+ const stream = controller . _stream ;
737+ assert ( stream . _state === 'writable' ) ;
738+
739+ controller . _releaseBackpressure = true ;
740+
741+ if ( WritableStreamHasOperationMarkedInFlight ( stream ) === false &&
742+ WritableStreamCloseQueuedOrInFlight ( stream ) === false ) {
743+ const backpressure = WritableStreamDefaultControllerGetBackpressure ( controller ) ;
744+ WritableStreamUpdateBackpressure ( stream , backpressure ) ;
745+ }
746+ }
747+
730748function WritableStreamDefaultControllerWrite ( controller , chunk , chunkSize ) {
731749 try {
732750 EnqueueValueWithSize ( controller , chunk , chunkSize ) ;
@@ -735,6 +753,8 @@ function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
735753 return ;
736754 }
737755
756+ controller . _releaseBackpressure = false ;
757+
738758 const stream = controller . _stream ;
739759 if ( WritableStreamCloseQueuedOrInFlight ( stream ) === false && stream . _state === 'writable' ) {
740760 const backpressure = WritableStreamDefaultControllerGetBackpressure ( controller ) ;
0 commit comments