MDN self-hosted library · e01.org

WritableStreamDefaultController

Streams

Streams

The WritableStreamDefaultController interface of the Streams API represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.

Constructor

None. WritableStreamDefaultController instances are created automatically during WritableStream construction.

Instance properties

  • WritableStreamDefaultController.signal
  • : Returns the AbortSignal associated with the controller.

Instance methods

  • WritableStreamDefaultController.error()
  • : Causes any future interactions with the associated stream to error.

Examples

const writableStream = new WritableStream({
  start(controller) {
    // do stuff with controller

    // error stream if necessary
    controller.error("My stream is broken");
  },
  write(chunk, controller) {
    // …
  },
  close() {
    // …
  },
  abort(err) {
    // …
  },
});

Specifications

Browser compatibility