Skip to content

Recall reject callback when request fails during batch #97

@ronan-gloo

Description

@ronan-gloo

Problem

The batchSend implementation of the Guzzle6Adapter never invoke the callback defined in the rejected option key when the request fails.

As a callback is set instead by the adapter, it is impossible to process errors when a call fails.

How to reproduce

  • Given : 2 requests, 1 success & 1 error
  • Expected : Both messages are displayed, means both callbacks were invoked
  • Actual : Only the fulfilled callback ("success") is reached
<?php
$halClient = (new Client())->getHalClient()->withToken('<api_key>');

$requests['success'] = $halClient->createRequest('GET', '/v1/ping'); // 200 here
$requests['error']      = $halClient->createRequest('GET', '/v1/pong'); // 404 here

$halClient->batchSend($requests, [
    'fulfilled' => function($response, $id) {
        echo "$id : OK\n";
    },
    'rejected' => function($exception, $id) {
        echo "$id : NOT OK\n";
    }
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions