Keep disabled FetchLaterAPI: fix net::ERR_TIMED_OUT (#2308)

also activates the API but denies the actual sending of the request
This commit is contained in:
Carmelo Messina
2025-09-10 11:38:47 +02:00
parent aabb7ddc60
commit 185dbf0bf1
@@ -13,10 +13,10 @@ License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
.../browser/loader/keep_alive_url_loader.h | 3 --
.../Keep-disabled-FetchLaterAPI.inc | 2 ++
.../renderer/core/fetch/fetch_manager.cc | 21 ++++++++++--
.../loader/child_url_loader_factory_bundle.cc | 14 ++++----
.../loader/child_url_loader_factory_bundle.cc | 16 +++++----
.../platform/loader/fetch/resource_fetcher.cc | 2 +-
.../platform/runtime_enabled_features.json5 | 4 +--
7 files changed, 63 insertions(+), 16 deletions(-)
7 files changed, 65 insertions(+), 16 deletions(-)
create mode 100644 cromite_flags/third_party/blink/common/features_cc/Keep-disabled-FetchLaterAPI.inc
diff --git a/content/browser/loader/keep_alive_url_loader.cc b/content/browser/loader/keep_alive_url_loader.cc
@@ -146,20 +146,22 @@ diff --git a/third_party/blink/renderer/core/fetch/fetch_manager.cc b/third_part
diff --git a/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc b/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
--- a/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
+++ b/third_party/blink/renderer/platform/loader/child_url_loader_factory_bundle.cc
@@ -250,6 +250,12 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
@@ -250,6 +250,14 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
return;
}
+ bool keepalive = request.keepalive;
+ if (keepalive && !request.is_fetch_later_api &&
+ url::IsSameOriginWith(request.url, request.referrer)) {
+ keepalive = false;
+ if (keepalive && !request.is_fetch_later_api) {
+ if (request.request_initiator && request.request_initiator->IsSameOriginWith(request.url))
+ keepalive = false;
+ else if (url::IsSameOriginWith(request.url, request.referrer))
+ keepalive = false;
+ }
+
// Use |keep_alive_loader_factory_| to send the keepalive requests to the
// KeepAliveURLLoaderService in the browser process and trigger the special
// keepalive request handling.
@@ -258,12 +264,8 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
@@ -258,12 +266,8 @@ void ChildURLLoaderFactoryBundle::CreateLoaderAndStart(
if (request.keepalive) {
FetchUtils::LogFetchKeepAliveRequestSentToServiceMetric(request);
}
@@ -195,8 +197,8 @@ diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5
// https://chromestatus.com/feature/4654499737632768
- name: "FetchLaterAPI",
- status: "stable",
+ name: "FetchLaterAPI", // disable
+ status: "experimental", // by default
+ name: "FetchLaterAPI", // disabled
+ status: "stable", // by default (note: idl must be active)
},
{
// The retry ability for Fetch keepalive requests.