Skip to content

Commit 8c10cc1

Browse files
authored
throw appropriate error for non-byob stream mode (#5748)
1 parent 4ecc4e5 commit 8c10cc1

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

src/workerd/api/streams/readable.c++

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ ReadableStream::Reader ReadableStream::getReader(
352352
KJ_IF_SOME(o, options) {
353353
KJ_IF_SOME(mode, o.mode) {
354354
JSG_REQUIRE(
355-
mode == "byob", RangeError, "mode must be undefined or 'byob' in call to getReader().");
355+
mode == "byob", TypeError, "mode must be undefined or 'byob' in call to getReader().");
356356
// No need to check that the ReadableStream implementation is a byte stream: the first
357357
// invocation of read() will do that for us and throw if necessary. Also, we should really
358358
// just support reading non-byte streams with BYOB readers.

src/wpt/streams-test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ export default {
328328
'readable-byte-streams/templated.any.js': {
329329
comment: 'To be investigated',
330330
expectedFailures: [
331-
'ReadableStream with byte source (empty): calling getReader with invalid arguments should throw appropriate errors',
332331
'ReadableStream with byte source (empty) BYOB reader: canceling via the reader should cause the reader to act closed',
333332
],
334333
},
@@ -438,8 +437,6 @@ export default {
438437
// TODO(conform): The spec allows error to be called with no argument at all, treating
439438
// it as undefined, currently we require that undefined is passed explicitly.
440439
'ReadableStreamDefaultReader closed promise should be rejected with undefined if that is the error',
441-
// TODO(conform): The spec expects this to be a TypeError, not a RangeError
442-
'getReader() should call ToString() on mode',
443440
],
444441
},
445442
'readable-streams/floating-point-total-queue-size.any.js': {
@@ -484,8 +481,6 @@ export default {
484481
"ReadableStream can't be constructed with garbage",
485482
// TODO(conform): We currently allow the empty type value
486483
"ReadableStream can't be constructed with an invalid type",
487-
// TODO(conform): The spec expects a TypeError here, not a RangeError
488-
'default ReadableStream getReader() should only accept mode:undefined',
489484
// TODO(conform): The spec expects us to call pull an extra time here despite. [Despite what? -NP]
490485
'ReadableStream: should pull after start, and after every read',
491486
// TODO(conform): The standard generally anticipates that the closed
@@ -581,7 +576,6 @@ export default {
581576
'ReadableStream reader (closed via cancel after getting reader): closed should fulfill with undefined',
582577
],
583578
expectedFailures: [
584-
'ReadableStream (empty): calling getReader with invalid arguments should throw appropriate errors',
585579
'ReadableStream reader (closed before getting reader): releasing the lock should cause closed to reject and change identity',
586580
'ReadableStream reader (closed after getting reader): releasing the lock should cause closed to reject and change identity',
587581
'ReadableStream reader (closed via cancel after getting reader): releasing the lock should cause closed to reject and change identity',

0 commit comments

Comments
 (0)