[11.x] Prevent crash when handling ConnectionException in HttpClient retry logic #50955
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, I have been using
HttpClient
to crawl some websites in order to extract data for personal purposes. During the crawler monitoring process, I noticed that many errors like the following appear:After reading through the source code at the error location, I found that when the
$response
variable is of typeConnectionException
, an error occurs at line 1058 because there is notoException()
method defined in theConnectionException
class.framework/src/Illuminate/Http/Client/PendingRequest.php
Line 1058 in 53a5aab
This pull request will add a condition to check the data type of the
$response
variable before passing it as a parameter to thevalue()
function. This approach is similar to other locations within the samehandlePromiseResponse()
function where the value is being used, so I think it will not affect other functionalities.I would appreciate if you could review and merge this patch.