Web/API/WritableStreamDefaultController

From Get docs

This is an experimental technologyCheck 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
StreamsThe definition of 'WritableStreamDefaultController' in that specification. Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

WritableStreamDefaultController

Experimental'

Chrome

Full support 58

Edge

Full support ≤18

Firefox

No support No

IE

No support No

Opera

Full support 45

Safari

?

WebView Android

Full support 58

Chrome Android

Full support 58

Firefox Android

No support No

Opera Android

Full support 43

Safari iOS

?

Samsung Internet Android

Full support 7.0

error

Experimental'

Chrome

?

Edge

Full support 16

Firefox

No support No

IE

No support No

Opera

?

Safari

?

WebView Android

?

Chrome Android

?

Firefox Android

No support No

Opera 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.