ReadableStreamDefaultReader: releaseLock() method
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
Parameters
Return value
Exceptions
-
TypeError
-
Thrown if the source object is not a ReadableStreamDefaultReader
.
Examples
function fetchStream() {
const reader = stream.getReader();
reader.releaseLock();
}
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
releaseLock |
78 |
79 |
65 |
No |
65 |
≤13.1 |
78 |
78 |
65 |
56 |
≤13.4 |
12.0 |
reject_pending_read_request |
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
102 |
No |
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
No |
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
102 |
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
No |
NoreleaseLock() throws if there are pending read requests (rather than pending read requests being rejected).
|
See also