Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject pending reads when releasing reader #1168

Merged
merged 33 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8cbe621
Assert there are no pending reads when releasing lock
MattiasBuelens Oct 1, 2021
74dba1e
Update spec text
MattiasBuelens Oct 1, 2021
b20b238
Allow releasing the lock in the middle of close/error steps
MattiasBuelens Oct 2, 2021
1aa5542
Reject all pending reads when releasing lock
MattiasBuelens Oct 14, 2021
a2dc7eb
Unexport ReadableStreamReaderGenericRelease
MattiasBuelens Dec 13, 2021
86d4ca6
Handle pending pull-into descriptors when releasing a reader
MattiasBuelens Dec 15, 2021
c7b72e2
Roll WPT
MattiasBuelens Dec 15, 2021
d69b63a
Assert there are no pending reads when releasing lock in tee()
MattiasBuelens Dec 15, 2021
33fbd3a
Reject closed promise before running error steps
MattiasBuelens Dec 15, 2021
8daae1a
Fix typo
MattiasBuelens Dec 15, 2021
698d82f
Copy chunk before enqueuing
MattiasBuelens Dec 15, 2021
c9cc2fd
Roll WPT
MattiasBuelens Dec 15, 2021
526d6eb
Call GenericRelease() first when releasing a default/BYOB reader
MattiasBuelens Jan 5, 2022
6dce52f
Add ErrorReadRequests helpers
MattiasBuelens Jan 5, 2022
829dc1a
Fix typo
MattiasBuelens Jan 5, 2022
d17b13c
Spec text: add ReadableByteStreamControllerFillReadRequestFromQueue
MattiasBuelens Jan 5, 2022
df361e0
Spec text: extract stream variable in ReadableStreamReaderGenericRelease
MattiasBuelens Jan 5, 2022
27d858d
Spec text: add [[ReleaseSteps]]
MattiasBuelens Jan 5, 2022
fa4a84b
Spec text: add ErrorReadRequests helpers
MattiasBuelens Jan 5, 2022
c11ce88
Tweak
MattiasBuelens Jan 5, 2022
e15d647
Spec text: allow releasing reader with pending reads
MattiasBuelens Jan 5, 2022
ad8b431
Spec text: restore removed asserts
MattiasBuelens Jan 5, 2022
4266d1d
Spec text: update documentation for web developers
MattiasBuelens Jan 5, 2022
052eeba
Remove manual IDs for new abstract ops
MattiasBuelens Jan 7, 2022
1e99d54
Put ifs with single step on one line
MattiasBuelens Jan 7, 2022
696cafd
Sort new abstract ops alphabetically
MattiasBuelens Jan 7, 2022
e4f614c
Fix EnqueueDetachedPullIntoToQueue() call
MattiasBuelens Jan 7, 2022
1e6abd7
Add ReadableByteStreamControllerEnqueueClonedChunkToQueue helper
MattiasBuelens Jan 7, 2022
a18d2c2
Fix variable name
MattiasBuelens Jan 7, 2022
e86aae8
Simplify ReadableByteStreamControllerEnqueue
MattiasBuelens Jan 7, 2022
510ebfd
Wrap some lines
MattiasBuelens Jan 11, 2022
46b29e0
Roll WPT
MattiasBuelens Jan 11, 2022
e9e78fe
Roll WPT
MattiasBuelens Jan 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow releasing the lock in the middle of close/error steps
  • Loading branch information
MattiasBuelens committed Jan 5, 2022
commit b20b23894927e4d9dbc249e928ef8eeecf5a5195
21 changes: 12 additions & 9 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2586,9 +2586,10 @@ the {{ReadableStream}}'s public API.
1. Perform ! [$ReadableStreamClose$](|stream|).
1. Let |reader| be |stream|.[=ReadableStream/[[reader]]=].
1. If |reader| is not undefined and |reader| [=implements=] {{ReadableStreamBYOBReader}},
1. [=list/For each=] |readIntoRequest| of |reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=],
1. Perform |readIntoRequest|'s [=read-into request/close steps=], given undefined.
1. Let |readIntoRequests| be |reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=].
1. Set |reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=] to an empty [=list=].
1. [=list/For each=] |readIntoRequest| of |readIntoRequests|,
1. Perform |readIntoRequest|'s [=read-into request/close steps=], given undefined.
1. Let |sourceCancelPromise| be !
|stream|.[=ReadableStream/[[controller]]=].[$ReadableStreamController/[[CancelSteps]]$](|reason|).
1. Return the result of [=reacting=] to |sourceCancelPromise| with a fulfillment step that returns
Expand All @@ -2605,9 +2606,10 @@ the {{ReadableStream}}'s public API.
1. If |reader| is undefined, return.
1. [=Resolve=] |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] with undefined.
1. If |reader| [=implements=] {{ReadableStreamDefaultReader}},
1. [=list/For each=] |readRequest| of |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=],
1. Perform |readRequest|'s [=read request/close steps=].
1. Let |readRequests| be |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=].
1. Set |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=] to an empty [=list=].
1. [=list/For each=] |readRequest| of |readRequests|,
1. Perform |readRequest|'s [=read request/close steps=].
</div>

<div algorithm>
Expand All @@ -2622,15 +2624,16 @@ the {{ReadableStream}}'s public API.
1. [=Reject=] |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] with |e|.
1. Set |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=].\[[PromiseIsHandled]] to true.
1. If |reader| [=implements=] {{ReadableStreamDefaultReader}},
1. [=list/For each=] |readRequest| of |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=],
1. Perform |readRequest|'s [=read request/error steps=], given |e|.
1. Let |readRequests| be |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=].
1. Set |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=] to a new empty [=list=].
1. [=list/For each=] |readRequest| of |readRequests|,
1. Perform |readRequest|'s [=read request/error steps=], given |e|.
1. Otherwise,
1. Assert: |reader| [=implements=] {{ReadableStreamBYOBReader}}.
1. [=list/For each=] |readIntoRequest| of
|reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=],
1. Perform |readIntoRequest|'s [=read-into request/error steps=], given |e|.
1. Let |readIntoRequests| be |reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=].
1. Set |reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=] to a new empty [=list=].
1. [=list/For each=] |readIntoRequest| of |readIntoRequests|,
1. Perform |readIntoRequest|'s [=read-into request/error steps=], given |e|.
</div>

<div algorithm>
Expand Down
22 changes: 12 additions & 10 deletions reference-implementation/lib/abstract-ops/readable-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,11 @@ function ReadableStreamCancel(stream, reason) {

const reader = stream._reader;
if (reader !== undefined && ReadableStreamBYOBReader.isImpl(reader)) {
for (const readIntoRequest of reader._readIntoRequests) {
const readIntoRequests = reader._readIntoRequests;
MattiasBuelens marked this conversation as resolved.
Show resolved Hide resolved
reader._readIntoRequests = [];
for (const readIntoRequest of readIntoRequests) {
readIntoRequest.closeSteps(undefined);
}
reader._readIntoRequests = [];
}

const sourceCancelPromise = stream._controller[CancelSteps](reason);
Expand All @@ -769,10 +770,11 @@ function ReadableStreamClose(stream) {
resolvePromise(reader._closedPromise, undefined);

if (ReadableStreamDefaultReader.isImpl(reader)) {
for (const readRequest of reader._readRequests) {
const readRequests = reader._readRequests;
reader._readRequests = [];
for (const readRequest of readRequests) {
readRequest.closeSteps();
}
reader._readRequests = [];
}
}

Expand All @@ -792,19 +794,19 @@ function ReadableStreamError(stream, e) {
setPromiseIsHandledToTrue(reader._closedPromise);

if (ReadableStreamDefaultReader.isImpl(reader)) {
for (const readRequest of reader._readRequests) {
const readRequests = reader._readRequests;
reader._readRequests = [];
for (const readRequest of readRequests) {
readRequest.errorSteps(e);
}

reader._readRequests = [];
} else {
assert(ReadableStreamBYOBReader.isImpl(reader));

for (const readIntoRequest of reader._readIntoRequests) {
const readIntoRequests = reader._readIntoRequests;
reader._readIntoRequests = [];
for (const readIntoRequest of readIntoRequests) {
readIntoRequest.errorSteps(e);
}

reader._readIntoRequests = [];
}
}

Expand Down