LibWeb: Always close remote media resource streams on a request error

Otherwise, the PlaybackManager may get stuck waiting for enough data to
read the metadata and call on_metadata_parsed.

This is unfortunately difficult to test without direct control over the
fetching process, but it could cause flakes in tests that wait for
loadeddata.
This commit is contained in:
Zaggy1024
2026-04-19 07:21:48 -05:00
committed by Gregory Bertilson
parent 973d3da0e7
commit 29d9667511
Notes: github-actions[bot] 2026-04-22 00:13:34 +00:00

View File

@@ -1279,6 +1279,7 @@ void HTMLMediaElement::load_remote_resource(ByteRange const& byte_range)
// NOTE: We do this step before creating the updateMedia task so that we can invoke the failure callback.
auto maybe_verify_response_failure = self->verify_response_or_get_failure_reason(response, byte_range);
if (maybe_verify_response_failure.has_value()) {
fetch_data->stream->close();
fetch_data->failure_callback(maybe_verify_response_failure.value());
return;
}
@@ -1328,6 +1329,8 @@ void HTMLMediaElement::load_remote_resource(ByteRange const& byte_range)
return;
if (fetch_generation != weak_self->m_current_fetch_generation)
return;
weak_self->m_remote_fetch_data->stream->close();
weak_self->queue_a_media_element_task([self = weak_self.as_nonnull()] {
self->process_media_data(FetchingStatus::Interrupted);
});