caseyamcl / guzzle_retry_middleware

Middleware for Guzzle v6/7+ that automatically retries HTTP requests on 429, 503 responses.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with basic implementation

nexxai opened this issue · comments

Detailed description

I followed the instructions as listed in the README.md file, however when I go to actually use the implementation, I get the following error when I try to initiate the GuzzleHttp client:

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleRetry\GuzzleRetryMiddleware;

class Example {
    public function test() {
        $stack = HandlerStack::create();
        $stack->push(GuzzleRetryMiddleware::factory());

        $client = new Client($stack);  // This is the line that is throwing an error
...

Error:

Expected type 'array'. Found 'GuzzleHttp\HandlerStack'.

I'm sure it's probably a user error, but it's a pretty simple implementation and I'm not sure where I may have messed up.

Versions

guzzle/guzzlehttp: 6.3.3
laravel/framework: 5.8.2

Turns out the documentation shows

$client = new Client($stack);

when it should be

$client = new Client([$stack]);

Submitted a PR to update the documentation accordingly.

Thanks for the doc fix! I've merged the pull request.