Firefox Tomorrow

web api instance method

WritableStream: abort() method

View on MDN ↗

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

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.