Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2022.
Note: This feature is available in Web Workers.
The error() method of the WritableStreamDefaultController interface causes any future interactions with the associated stream to error.
This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the normal lifecycle of interactions with the underlying sink.
A string representing the error you want future interactions to fail with.
None (undefined).
The stream you are trying to error is not a WritableStream.
| Streams # ref-for-ws-default-controller-error① |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 28, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.