We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS


This page is not complete.

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The ReadableStreamDefaultController() constructor creates and returns a ReadableStreamDefaultController() object instance.

Note: You wouldn't use this constructor manually — this is used during the construction of a ReadableStream object.


var readableStreamController = new ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark);


The ReadableStream to be controlled.
An object containing methods and properties that define how the constructed stream instance will behave. See the ReadableStream() constructor's parameters definitions for more information.
A method containing a parameter chunk — this indicates the size to use for each chunk, in bytes.
A non-negative integer — this defines the total number of chunks that can be contained in the internal queue before backpressure is applied.

Return value

An instance of the ReadableStreamDefaultController object.


The supplied stream parameter is not a ReadableStream, or it already has an associated controller.


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.

const stream = new ReadableStream({
  start(controller) {
    interval = setInterval(() => {
      let string = randomChars();

      // Add the string to the stream

      // show it on the screen
      let listItem = document.createElement('li');
      listItem.textContent = string;
    }, 1000);

    button.addEventListener('click', function() {
  pull(controller) {
    // We don't really need a pull in this example
  cancel() {
    // This is called if the reader cancels,
    // so we should stop generating strings


Specification Status Comment
The definition of 'ReadableStreamDefaultController()' in that specification.
Living Standard Initial definition.

Browser compatibility

No compatibility data found. Please contribute data for "path.to.feature.NameOfTheConstructor" (depth: 1) to the MDN compatibility data repository.

Document Tags and Contributors

Contributors to this page: chrisdavidmills
Last updated by: chrisdavidmills,