Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
The ReadableStreamDefaultController interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue. Default controllers are for streams that are not byte streams.
None. ReadableStreamDefaultController instances are created automatically during ReadableStream construction.
Returns the desired size required to fill the stream's internal queue.
Closes the associated stream.
ReadableStreamDefaultController.enqueue()Enqueues a given chunk in the associated stream.
ReadableStreamDefaultController.error()Causes any future interactions with the associated stream to error.
In the following simple example, a custom ReadableStream is created using a constructor (see our Simple random stream example for the full code). The start() function generates a random string of text every second and enqueues it into the stream. A cancel() function is also provided to stop the generation if ReadableStream.cancel() is called for any reason.
Note that a ReadableStreamDefaultController object is provided as the parameter of the start() and pull() functions.
When a button is pressed, the generation is stopped, the stream is closed using ReadableStreamDefaultController.close(), and another function is run, which reads the data back out of the stream.
| Streams # rs-default-controller-class |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Sep 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.