Skip to content

Commit 6523522

Browse files
authored
Merge pull request #5777 from cloudflare/yagiz/writable-stream-js-controller-underlying-sink
WritableStream can't be constructed with a defined type
2 parents 4562f50 + d0a2a70 commit 6523522

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,6 +3490,14 @@ void WritableStreamJsController::setup(jsg::Lock& js,
34903490
jsg::Optional<StreamQueuingStrategy> maybeQueuingStrategy) {
34913491
auto underlyingSink = kj::mv(maybeUnderlyingSink).orDefault({});
34923492
auto queuingStrategy = kj::mv(maybeQueuingStrategy).orDefault({});
3493+
3494+
if (FeatureFlags::get(js).getPedanticWpt()) {
3495+
// Per the spec, the type property for WritableStream's underlying sink must be undefined.
3496+
// If it's anything else, throw a RangeError.
3497+
JSG_REQUIRE(underlyingSink.type == kj::none, RangeError,
3498+
"Invalid underlying sink type. Only undefined is valid.");
3499+
}
3500+
34933501
// We account for the memory usage of the WritableStreamDefaultController and AbortSignal together
34943502
// because their lifetimes are identical and memory accounting itself has a memory overhead.
34953503
state = js.allocAccounted<WritableStreamDefaultController>(

src/wpt/streams-test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,12 +747,10 @@ export default {
747747
? [
748748
'controller argument should be passed to start method',
749749
'WritableStream should be writable and ready should fulfill immediately if the strategy does not apply backpressure',
750-
"WritableStream can't be constructed with a defined type",
751750
]
752751
: [
753752
'controller argument should be passed to start method',
754753
'WritableStream should be writable and ready should fulfill immediately if the strategy does not apply backpressure',
755-
"WritableStream can't be constructed with a defined type",
756754
'underlyingSink argument should be converted after queuingStrategy argument',
757755
],
758756
},

0 commit comments

Comments
 (0)