@@ -27,6 +27,7 @@ Object.assign(exports, {
27
27
WritableStreamDefaultControllerClearAlgorithms,
28
28
WritableStreamDefaultControllerError,
29
29
WritableStreamDefaultControllerErrorIfNeeded,
30
+ WritableStreamDefaultControllerReleaseBackpressure,
30
31
WritableStreamDefaultWriterAbort,
31
32
WritableStreamDefaultWriterClose,
32
33
WritableStreamDefaultWriterCloseWithErrorPropagation,
@@ -543,6 +544,7 @@ function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm
543
544
544
545
controller . _abortController = new AbortController ( ) ;
545
546
controller . _started = false ;
547
+ controller . _releaseBackpressure = false ;
546
548
547
549
controller . _strategySizeAlgorithm = sizeAlgorithm ;
548
550
controller . _strategyHWM = highWaterMark ;
@@ -657,6 +659,9 @@ function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
657
659
}
658
660
659
661
function WritableStreamDefaultControllerGetBackpressure ( controller ) {
662
+ if ( controller . _releaseBackpressure === true ) {
663
+ return false ;
664
+ }
660
665
const desiredSize = WritableStreamDefaultControllerGetDesiredSize ( controller ) ;
661
666
return desiredSize <= 0 ;
662
667
}
@@ -727,6 +732,19 @@ function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
727
732
) ;
728
733
}
729
734
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
+
730
748
function WritableStreamDefaultControllerWrite ( controller , chunk , chunkSize ) {
731
749
try {
732
750
EnqueueValueWithSize ( controller , chunk , chunkSize ) ;
@@ -735,6 +753,8 @@ function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
735
753
return ;
736
754
}
737
755
756
+ controller . _releaseBackpressure = false ;
757
+
738
758
const stream = controller . _stream ;
739
759
if ( WritableStreamCloseQueuedOrInFlight ( stream ) === false && stream . _state === 'writable' ) {
740
760
const backpressure = WritableStreamDefaultControllerGetBackpressure ( controller ) ;
0 commit comments