From e2c935475f615cc7b5ebf83a2aec806d11be394f Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Tue, 26 Aug 2025 14:44:31 +0100 Subject: [PATCH] LibWeb/Fetch: Enable callbacks in the abort signal algorithm callback If the request has a body, the abort will interact with promises, which requires callbacks to be enabled. Fixes crashing on Atlassian products. --- Libraries/LibWeb/Fetch/FetchMethod.cpp | 2 +- ...r-abort-with-body-does-not-crash-with-timeout.txt | 1 + ...-abort-with-body-does-not-crash-with-timeout.html | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.txt create mode 100644 Tests/LibWeb/Text/input/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.html diff --git a/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Libraries/LibWeb/Fetch/FetchMethod.cpp index eafa2c6b737..667a10a3b14 100644 --- a/Libraries/LibWeb/Fetch/FetchMethod.cpp +++ b/Libraries/LibWeb/Fetch/FetchMethod.cpp @@ -143,7 +143,7 @@ GC::Ref fetch(JS::VM& vm, RequestInfo const& input, RequestInit controller_holder->controller()->abort(relevant_realm, request_object->signal()->reason()); // AD-HOC: An execution context is required for Promise functions. - HTML::TemporaryExecutionContext execution_context { relevant_realm }; + HTML::TemporaryExecutionContext execution_context { relevant_realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes }; // 4. Abort the fetch() call with p, request, responseObject, and requestObject’s signal’s abort reason. abort_fetch(relevant_realm, *promise_capability, request, response_object, request_object->signal()->reason()); diff --git a/Tests/LibWeb/Text/expected/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.txt b/Tests/LibWeb/Text/expected/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.txt new file mode 100644 index 00000000000..50586a4cbfb --- /dev/null +++ b/Tests/LibWeb/Text/expected/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.txt @@ -0,0 +1 @@ +PASS! (Didn't crash) diff --git a/Tests/LibWeb/Text/input/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.html b/Tests/LibWeb/Text/input/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.html new file mode 100644 index 00000000000..217a54e957e --- /dev/null +++ b/Tests/LibWeb/Text/input/Fetch/fetch-controller-abort-with-body-does-not-crash-with-timeout.html @@ -0,0 +1,12 @@ + + +