Skip to content

TypeError with HTTP Client  #49909

Closed
@NKozhuharov

Description

@NKozhuharov

Laravel Version

10.42.0

PHP Version

8.3

Database Driver & Version

No response

Description

Looks like a similar issue existed before - #37596.

Relevant stack trace:

TypeError: Illuminate\Http\Client\Events\ConnectionFailed::__construct(): Argument #1 ($request) must be of type Illuminate\Http\Client\Request, null given, called in /code/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 1424
#67 /vendor/laravel/framework/src/Illuminate/Http/Client/Events/ConnectionFailed.php(22): Illuminate\Http\Client\Events\ConnectionFailed::__construct
#66 /vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(1424): Illuminate\Http\Client\PendingRequest::dispatchConnectionFailedEvent
#65 /vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(924): Illuminate\Http\Client\PendingRequest::Illuminate\Http\Client\{closure}
#64 /vendor/laravel/framework/src/Illuminate/Support/helpers.php(248): retry
#63 /vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(892): Illuminate\Http\Client\PendingRequest::send
#62 /vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(770): Illuminate\Http\Client\PendingRequest::get

Steps To Reproduce

It happens sometimes, when calling

public function get(string $endpoint, array $query = [], int $tries = 3, int $timeout = 60): Response {
    $headers = [
        'X-Shopify-Access-Token' => 'my-token',
        'Content-Type'           => 'application/json',
    ];
    $response = Http::setClient(Http::buildClient())->withHeaders($headers)->timeout(60)->get($this->url($endpoint, $query));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions