This feature is well established and works across many devices and browser versions. It’s been available across browsers since June 2022.
Note: This feature is available in Web Workers.
The desiredSize read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
The internal queue of a ReadableStream contains chunks that have been enqueued, but not yet read. The browser determines the desired size to fill the stream, and it is this value returned by the desiredSize property.
If the desiredSize is 0 then the queue is full. Therefore you can use this information to manually apply backpressure to manage the queue.
The desired size.
In the next example the desiredSize is logged to the console.
console.log(controller.desiredSize);
| Specification |
|---|
| Streams> # ts-default-controller-desired-size> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
desiredSize |
67 | 79 | 102 | 54 | 14.1 | 67 | 102 | 48 | 14.5 | 9.0 | 67 | 14.5 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TransformStreamDefaultController/desiredSize