This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
The error() method of the ReadableStreamDefaultController interface causes any future interactions with the associated stream to error.
Note: The error() method can be called more than once, and can be called when the stream is not readable.
error(e)
eThe error you want future interactions to fail with.
None (undefined).
TypeErrorThrown if the source object is not a ReadableStreamDefaultController.
The A readable stream with an underlying push source and backpressure support example in the spec provides a good example of using ReadableStreamDefaultController.desiredSize to manually detect when the stream is full and apply backpressure, and also of using error() to manually trigger a stream error if another part of the system it relies on fails.
| Specification |
|---|
| Streams> # rs-default-controller-error> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
error |
52 | 79 | 65 | 39 | 10 | 52 | 65 | 41 | 10 | 6.0 | 52 | 10 |
© 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/ReadableStreamDefaultController/error