WritableStreamDefaultController

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

The WritableStreamDefaultController interface of the 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.

Properties

None.

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(controller) {
    ...
  },
  abort(err) {
    ...
  }
});

Specifications

Specification Status Comment
Streams
The definition of 'WritableStreamDefaultController' in that specification.
Living Standard Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
WritableStreamDefaultController
Experimental
Chrome Full support 58Edge Full support ≤18Firefox No support NoIE ? Opera Full support 45Safari ? WebView Android Full support 58Chrome Android Full support 58Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 7.0
error
Experimental
Chrome ? Edge Full support 16Firefox No support NoIE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.