Skip to content

Commit 5585a5c

Browse files
committed
WritableStream can't be constructed with a defined type
1 parent e43a3f5 commit 5585a5c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,6 +3490,16 @@ 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+
KJ_IF_SOME(type, underlyingSink.type) {
3498+
JSG_REQUIRE(
3499+
type.size() == 0, RangeError, "Invalid type '", type, "'. Only undefined is valid.");
3500+
}
3501+
}
3502+
34933503
// We account for the memory usage of the WritableStreamDefaultController and AbortSignal together
34943504
// because their lifetimes are identical and memory accounting itself has a memory overhead.
34953505
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)