ReadableStreamDefaultReader: releaseLock() method

Baseline Widely available

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 releaseLock() method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.

If the associated stream is errored when the lock is released, the reader will appear errored in that same way subsequently; otherwise, the reader will appear closed.

If the reader's lock is released while it still has pending read requests then the promises returned by the reader's ReadableStreamDefaultReader.read() method are immediately rejected with a TypeError. Unread chunks remain in the stream's internal queue and can be read later by acquiring a new reader.

Syntax

js
releaseLock()

Parameters

None.

Return value

None (undefined).

Exceptions

TypeError

Thrown if the source object is not a ReadableStreamDefaultReader.

Examples

js
function fetchStream() {
  const reader = stream.getReader();

  // …

  reader.releaseLock();

  // …
}

Specifications

Specification
Streams
# ref-for-default-reader-release-lock②

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
releaseLock
Chrome – Full support
Chrome 43 (Release date: 2015-05-19)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 65 (Release date: 2019-01-29)
footnote Full support
Opera – Full support
Opera 30 (Release date: 2015-06-09)
footnote Full support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 43 (Release date: 2015-05-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 65 (Release date: 2019-01-29)
footnote Full support
Opera Android – Full support
Opera Android 30 (Release date: 2015-06-10)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – Full support
WebView Android 43 (Release date: 2015-05-27)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 16.5 (Release date: 2021-07-14)
footnote Full support
releaseLock() rejects pending read requests
Chrome – Full support
Chrome 105 (Release date: 2022-09-02)
footnote
footnote Before version 105, releaseLock() throws instead of rejecting.
Edge – Full support
Edge 105 (Release date: 2022-09-01)
footnote
footnote Before version 105, releaseLock() throws instead of rejecting.
Firefox – Full support
Firefox 102 (Release date: 2022-06-28)
footnote Full support
Opera – Full support
Opera 91 (Release date: 2022-09-14)
footnote
footnote Before version 91, releaseLock() throws instead of rejecting.
Safari – Full support
Safari 17 (Release date: 2023-09-18)
footnote Full support
Chrome Android – Full support
Chrome Android 105 (Release date: 2022-09-02)
footnote
footnote Before version 105, releaseLock() throws instead of rejecting.
Firefox for Android – Full support
Firefox for Android 102 (Release date: 2022-06-28)
footnote Full support
Opera Android – Full support
Opera Android 72 (Release date: 2022-10-21)
footnote
footnote Before version 72, releaseLock() throws instead of rejecting.
Safari on iOS – Full support
Safari on iOS 17 (Release date: 2023-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 20 (Release date: 2023-02-10)
footnote
footnote Before version 20.0, releaseLock() throws instead of rejecting.
WebView Android – Full support
WebView Android 105 (Release date: 2022-09-02)
footnote
footnote Before version 105, releaseLock() throws instead of rejecting.
WebView on iOS – Full support
WebView on iOS 17 (Release date: 2023-09-18)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1.18 (Release date: 2022-01-20)
footnote Full support
Node.js – Full support
Node.js 18.9 (Release date: 2022-09-08)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

See also