This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2022.
* Some parts of this feature may have varying levels of support.
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.
None. WritableStreamDefaultController instances are created automatically during WritableStream construction.
WritableStreamDefaultController.signal Read only
Returns the AbortSignal associated with the controller.
WritableStreamDefaultController.error()Causes any future interactions with the associated stream to error.
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) {
// …
},
});
| Specification |
|---|
| Streams> # ws-default-controller-class> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
WritableStreamDefaultController |
59 | 16 | 100 | 46 | 14.1 | 59 | 100 | 43 | 14.5 | 7.0 | 59 | 14.5 |
error |
59 | 16 | 100 | 46 | 14.1 | 59 | 100 | 43 | 14.5 | 7.0 | 59 | 14.5 |
signal |
98 | 98 | 100 | 84 | 16.4 | 98 | 100 | 68 | 16.4 | 18.0 | 98 | 16.4 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultController