| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader/cancel | [Back] [Original] |
Get to know MDN better
Since March 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Note: This feature is available in Web Workers.
The cancel() method of the ReadableStreamBYOBReader interface returns a Promise that resolves when the stream is canceled.
Calling this method signals a loss of interest in the stream by a consumer.
Note:
If the reader is active, the cancel() method behaves the same as that for the associated stream (ReadableStream.cancel()).
cancel()
cancel(reason)
reason OptionalA human-readable reason for the cancellation. The underlying source may or may not use it.
A Promise, which fulfills with the value given in the reason parameter.
TypeErrorThe source object is not a ReadableStreamBYOBReader, or the stream has no owner.
This example code calls the cancel() method when a button is pressed, passing the string "user choice" as a reason.
The promise resolves when cancellation completes.
button.addEventListener("click", () => {
reader.cancel("user choice").then(() => console.log(`cancel complete`));
});
Note that this code can be seen running in the Using readable byte streams example code (press the Cancel stream button).
| Specification |
|---|
| Streams # ref-for-generic-reader-cancel |
ReadableStreamBYOBReader() constructorThis page was last modified on Jul 26, 2024 by MDN contributors.
ReadableStreamBYOBReaderByteLengthQueuingStrategyCountQueuingStrategyReadableByteStreamControllerReadableStreamReadableStreamBYOBRequestReadableStreamDefaultControllerReadableStreamDefaultReaderResponse.bodyTransformStreamTransformStreamDefaultControllerWindow.fetch()WritableStreamWritableStreamDefaultControllerWritableStreamDefaultWriterYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |