From b7f537c863ded968eb5c2e0f12fa8ca93449e5e8 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 12 Nov 2025 21:44:15 +0100 Subject: [PATCH] Fix HTTPRequest timeout being scaled with `Engine.time_scale` The server's response time won't change according to the engine's time scale, so the timeout shouldn't be adjusted accordingly. --- doc/classes/HTTPRequest.xml | 3 ++- scene/main/http_request.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index b3fdc0363a8..ff87a3eb57d 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -253,7 +253,8 @@ Maximum number of allowed redirects. - The duration to wait in seconds before a request times out. If [member timeout] is set to [code]0.0[/code] then the request will never time out. For simple requests, such as communication with a REST API, it is recommended that [member timeout] is set to a value suitable for the server response time (e.g. between [code]1.0[/code] and [code]10.0[/code]). This will help prevent unwanted timeouts caused by variation in server response times while still allowing the application to detect when a request has timed out. For larger requests such as file downloads it is suggested the [member timeout] be set to [code]0.0[/code], disabling the timeout functionality. This will help to prevent large transfers from failing due to exceeding the timeout value. + The duration to wait before a request times out, in seconds (independent of [member Engine.time_scale]). If [member timeout] is set to [code]0.0[/code], the request will never time out. + For simple requests, such as communication with a REST API, it is recommended to set [member timeout] to a value suitable for the server response time (commonly between [code]1.0[/code] and [code]10.0[/code]). This will help prevent unwanted timeouts caused by variation in response times while still allowing the application to detect when a request has timed out. For larger requests such as file downloads, it is recommended to set [member timeout] to [code]0.0[/code], disabling the timeout functionality. This will help prevent large transfers from failing due to exceeding the timeout value. If [code]true[/code], multithreading is used to improve performance. diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 68c9c3541ac..25df9cf44b9 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -667,6 +667,7 @@ HTTPRequest::HTTPRequest() { tls_options = TLSOptions::client(); timer = memnew(Timer); timer->set_one_shot(true); + timer->set_ignore_time_scale(true); timer->connect("timeout", callable_mp(this, &HTTPRequest::_timeout)); add_child(timer); }