diff --git a/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp b/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp index 27caa53435..45e68750ea 100644 --- a/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp +++ b/Userland/Libraries/LibWeb/Streams/UnderlyingSource.cpp @@ -26,13 +26,13 @@ JS::ThrowCompletionOr UnderlyingSource::from_value(JS::VM& vm, .auto_allocate_chunk_size = {}, }; - if (TRY(object.has_property("type"))) { - auto type_value = TRY(TRY(object.get("type")).to_string(vm)); - if (type_value == "bytes"sv) { + auto type_value = TRY(object.get("type")); + if (!type_value.is_undefined()) { + auto type_string = TRY(type_value.to_string(vm)); + if (type_string == "bytes"sv) underlying_source.type = ReadableStreamType::Bytes; - } else { + else return vm.throw_completion(DeprecatedString::formatted("Unknown stream type '{}'", type_value)); - } } if (TRY(object.has_property("autoAllocateChunkSize")))