Skip to content

QueryBus with FinalizeGuard enabled returns null #24

Closed
@lezhnev74

Description

@lezhnev74

Hi, I am lost with FinalizeGuard and how to set it up properly. I am not sure if this relates to Laravel package or to MessageBus core.

  1. I have my query and corresponding finder. On success it resolves Deferred like this:
class QueryFinder {
    function __invoke($query, Deferred $deferred = null): void
    {
        //...
        $deferred->resolve($query_result);
    }
}
  1. I enabled FinalizeGuard in prooph.php config file.

  2. But the result of the query returns null.

// I use facade
$query_result = QueryBus::resultFrom($query);
// $query_result is null now
  1. If I disable the FinalizeGuard then query returns valid result. So it led me into looking inside of the FinalizeGuard code.

  2. Looking at 48 line: https://github.com/prooph/service-bus/blob/c239acfd43cf8eec577e30ce0aa7da86d87b6191/src/Plugin/Guard/FinalizeGuard.php#L48
    It creates a new Promise and here it losts resolved result.

It seems that I misuse QueryBus. Can you suggest the right way of resolving Deferred object inside my QueryFinder which works with FinalizeGuard?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions