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

Various fixes for readable byte streams #1123

Merged
merged 44 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c11ed1c
Throw when trying to enqueue/close after the BYOB request has been de…
MattiasBuelens Apr 9, 2021
be2cc14
Fix some links
MattiasBuelens Apr 9, 2021
858bebc
Ensure new view's buffer has same capacity as BYOB request's initial …
MattiasBuelens Apr 9, 2021
933db51
Allow passing a smaller view to BYOBRequest.respondWithNewView
MattiasBuelens Mar 20, 2021
b27f364
Allow passing an empty view to respondWithNewView() in closed state
MattiasBuelens Apr 9, 2021
01b6e78
Restrict pull-into descriptor's byte length to be non-zero
MattiasBuelens Apr 9, 2021
ec2af19
Fix check to match ReadableByteStreamControllerRespondInReadableState
MattiasBuelens Apr 16, 2021
7fdb8a5
Roll WPT
MattiasBuelens Apr 16, 2021
c475de8
Remove redundant check
MattiasBuelens Apr 17, 2021
98415ae
Fix missing ! before calls
MattiasBuelens Apr 19, 2021
22c5aa8
Add CanTransferArrayBuffer helper
MattiasBuelens Apr 19, 2021
882fc7c
Check [[ArrayBufferDetachKey]] in CanTransferArrayBuffer
MattiasBuelens Apr 19, 2021
afd3e81
Remove detached check from ReadableByteStreamController.close()
MattiasBuelens Apr 19, 2021
3d13462
Move detached pull-into buffer check to ReadableByteStreamControllerE…
MattiasBuelens Apr 19, 2021
2e55eda
Assert that pull-into descriptor is transferable in ReadableByteStrea…
MattiasBuelens Apr 19, 2021
ec48c0d
Check that respondWithNewView() is called with a transferable buffer
MattiasBuelens Apr 19, 2021
6608188
Check that enqueue() is called with a transferable buffer
MattiasBuelens Apr 19, 2021
6d4ea40
Remove redundant assert
MattiasBuelens Apr 19, 2021
63e4ced
Move checks for bytesWritten from RespondInternal() to Respond() and …
MattiasBuelens Apr 19, 2021
098889f
Don't error the stream if enqueue() fails because of a transferred BY…
MattiasBuelens Apr 19, 2021
efed1f5
Roll WPT
MattiasBuelens Apr 19, 2021
326ec81
Fix error message
MattiasBuelens Apr 19, 2021
7dad495
Check that view passed to byobReader.read() is transferable
MattiasBuelens Apr 19, 2021
e7b82bd
Always transfer the buffer when committing a pull-into descriptor
MattiasBuelens Apr 21, 2021
1b28987
Roll WPT
MattiasBuelens Apr 21, 2021
1002710
Always transfer first pull-into descriptor after enqueue() or respond()
MattiasBuelens Apr 23, 2021
458f95c
Move check up a bit
MattiasBuelens Apr 23, 2021
ea2aa01
Invalidate BYOB request on every enqueue(), respond() or respondWithN…
MattiasBuelens Apr 23, 2021
5da8d5c
Roll WPT
MattiasBuelens Apr 23, 2021
9382dc3
Make TransferArrayBuffer throw if the given buffer is non-transferable
MattiasBuelens May 17, 2021
5d2c90a
Add note about transferring WebAssembly.Memory buffers
MattiasBuelens May 17, 2021
c0f3a2d
Propagate transfer errors in ReadableByteStreamControllerEnqueue
MattiasBuelens May 18, 2021
1a20a27
Propagate transfer errors in ReadableByteStreamControllerRespond
MattiasBuelens May 18, 2021
0b7850c
Propagate transfer errors in ReadableByteStreamControllerRespondWithN…
MattiasBuelens May 18, 2021
17d1c2d
Relax check in ReadableByteStreamControllerEnqueue
MattiasBuelens May 18, 2021
78d4a1a
Propagate transfer errors in ReadableByteStreamControllerPullInto
MattiasBuelens May 18, 2021
0ab00d1
Use ≤ instead of <=
MattiasBuelens May 19, 2021
01b7779
Fix link to WebAssembly.Memory
MattiasBuelens May 19, 2021
bf4e8a3
Roll WPT
MattiasBuelens May 19, 2021
fb8d710
Ignore tests with non-transferable buffers
MattiasBuelens May 19, 2021
5d0f3ab
Roll WPT
MattiasBuelens May 20, 2021
c50c9bc
Fix typo
MattiasBuelens May 20, 2021
30b3f50
Add note about respondWithNewView
MattiasBuelens May 21, 2021
b22d61f
Roll WPT
MattiasBuelens May 26, 2021
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
8 changes: 8 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,10 @@ has the following [=struct/items=]:
exception.
1. If [=this=].[=ReadableStreamGenericReader/[[stream]]=].[=ReadableStream/[[state]]=] is not
"`readable`", throw a {{TypeError}} exception.
1. If [=this=].[=ReadableByteStreamController/[[pendingPullIntos]]=] is not [=list/is empty|empty=],
1. Let |firstDescriptor| be [=this=].[=ReadableByteStreamController/[[pendingPullIntos]]=][0].
1. If [$IsDetachedBuffer$](|firstDescriptor|'s [=pull-into descriptor/buffer=]) is true,
throw a {{TypeError}} exception.
1. Perform ? [$ReadableByteStreamControllerClose$]([=this=]).
</div>

Expand All @@ -1819,6 +1823,10 @@ for="ReadableByteStreamController">enqueue(|chunk|)</dfn> method steps are:
exception.
1. If [=this=].[=ReadableStreamGenericReader/[[stream]]=].[=ReadableStream/[[state]]=] is not
"`readable`", throw a {{TypeError}} exception.
1. If [=this=].[=ReadableByteStreamController/[[pendingPullIntos]]=] is not [=list/is empty|empty=],
1. Let |firstDescriptor| be [=this=].[=ReadableByteStreamController/[[pendingPullIntos]]=][0].
1. If [$IsDetachedBuffer$](|firstDescriptor|'s [=pull-into descriptor/buffer=]) is true,
throw a {{TypeError}} exception.
1. Return ! [$ReadableByteStreamControllerEnqueue$]([=this=], |chunk|).
</div>

Expand Down
15 changes: 15 additions & 0 deletions reference-implementation/lib/ReadableByteStreamController-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const assert = require('assert');

const { CancelSteps, PullSteps } = require('./abstract-ops/internal-methods.js');
const { ResetQueue } = require('./abstract-ops/queue-with-sizes.js');
const { IsDetachedBuffer } = require('./abstract-ops/ecmascript.js');
const aos = require('./abstract-ops/readable-streams.js');

const ReadableStreamBYOBRequest = require('../generated/ReadableStreamBYOBRequest.js');
Expand Down Expand Up @@ -38,6 +39,13 @@ exports.implementation = class ReadableByteStreamControllerImpl {
throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be closed`);
}

if (this._pendingPullIntos.length > 0) {
const firstDescriptor = this._pendingPullIntos[0];
if (IsDetachedBuffer(firstDescriptor.buffer) === true) {
throw new TypeError('The BYOB request\'s buffer has been detached');
}
}

aos.ReadableByteStreamControllerClose(this);
}

Expand All @@ -58,6 +66,13 @@ exports.implementation = class ReadableByteStreamControllerImpl {
throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be enqueued to`);
}

if (this._pendingPullIntos.length > 0) {
const firstDescriptor = this._pendingPullIntos[0];
if (IsDetachedBuffer(firstDescriptor.buffer) === true) {
throw new TypeError('The BYOB request\'s buffer has been detached');
}
}

aos.ReadableByteStreamControllerEnqueue(this, chunk);
}

Expand Down