web api instance method
WritableStream: abort() method
Available in workers
The abort() method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
Syntax
abort(reason)
Parameters
reason- : A string providing a human-readable reason for the abort.
Return value
A Promise, which fulfills with undefined.
Exceptions
TypeError- : The stream you are trying to abort is not a
WritableStream, or it is locked.
- : The stream you are trying to abort is not a
Examples
const writableStream = new WritableStream(
{
write(chunk) {
// …
},
close() {
// …
},
abort(err) {
// …
},
},
queuingStrategy,
);
// …
// abort the stream later on, when required
writableStream.abort();
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.