W3cubDocs

/Web APIs

WritableStreamDefaultController

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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
WritableStreamDefaultController 59 16 100 No 46 14.1 59 59 100 43 14.5 7.0
error 59 16 100 No 46 14.1 59 59 100 43 14.5 7.0
signal 98 98 100 No 84 16.4 98 98 100 68 16.4 18.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultController