From e18fb7fc93023e67653a2e9ec34f497035fbd51c Mon Sep 17 00:00:00 2001 From: Glenn Skrzypczak Date: Sun, 24 Nov 2024 20:39:32 +0100 Subject: [PATCH] LibWeb/Fetch: Handle streams on abort When aborting fetch, the request stream now gets closed and the response stream errors. --- Libraries/LibWeb/Fetch/FetchMethod.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Libraries/LibWeb/Fetch/FetchMethod.cpp index 38a7c65eca4..7a95e4d45f2 100644 --- a/Libraries/LibWeb/Fetch/FetchMethod.cpp +++ b/Libraries/LibWeb/Fetch/FetchMethod.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -163,8 +164,8 @@ void abort_fetch(JS::Realm& realm, WebIDL::Promise const& promise, GC::Refbody().get_pointer>(); body != nullptr && (*body)->stream()->is_readable()) { - // TODO: Implement cancelling streams - (void)error; + // NOTE: Cancel here is different than the cancel method of stream and refers to https://streams.spec.whatwg.org/#readablestream-cancel + Streams::readable_stream_cancel((*body)->stream(), error); } // 3. If responseObject is null, then return. @@ -178,8 +179,7 @@ void abort_fetch(JS::Realm& realm, WebIDL::Promise const& promise, GC::Refbody()) { auto stream = response->body()->stream(); if (stream->is_readable()) { - // TODO: Implement erroring streams - (void)error; + stream->error(error); } } }