Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpClient] Fixes max_duration not being respected #46330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixes max_duration not being respected
As reported on #46316, when a request gets a successful response in further attempts, the max_duration is not respected and the request may take longer than the value specified here.

My way to solve the issue was by reducing the timeout option in future requests, making it smaller in every attempt. By doing so, the total time of a $client->request will never be much longer than max_duration. Perhaps a second or two maybe, due to the waiting time between requests, but not as much as the timeout.
  • Loading branch information
r-martins authored May 12, 2022
commit deb67aa945061bee838de68de37c69ac7fb3086e
8 changes: 8 additions & 0 deletions 8 src/Symfony/Component/HttpClient/Response/AsyncContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ public function replaceRequest(string $method, string $url, array $options = [])
$onProgress($dlNow, $dlSize, $thisInfo + $info);
};
}

if ($maxDuration = $options['max_duration'] ?? false) {
$totalElapsed = 0;
foreach ($this->info['previous_info'] as $req) {
$totalElapsed += $req['total_time'];
}
$options['timeout'] = ceil($maxDuration - $totalElapsed);
}

return $this->response = $this->client->request($method, $url, ['buffer' => false] + $options);
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.