WritableStreamDefaultController

Note: This feature is available in Web Workers.

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 Read only

Returns the AbortSignal associated with the controller.

Instance methods

WritableStreamDefaultController.error()

Causes any future interactions with the associated stream to error.

Examples

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

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

Specifications

Specification
Streams
# ws-default-controller-class

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
WritableStreamDefaultController
error
signal

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.