Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Throw error when callback doesn't return a promise #3

Closed
jvdlaar opened this issue Aug 1, 2018 · 0 comments · Fixed by #4
Closed

[Feature request] Throw error when callback doesn't return a promise #3

jvdlaar opened this issue Aug 1, 2018 · 0 comments · Fixed by #4
Labels
enhancement New feature or request

Comments

@jvdlaar
Copy link

jvdlaar commented Aug 1, 2018

    $subscription = $connection->connectToPersistentSubscriptionAsync(
        'foo-bar',
        'test-persistent-subscription',
        function (EventStorePersistentSubscription $subscription, ResolvedEvent $event, int $retry) use ($stopWatch, &$i)/*: Promise*/ {
            echo 'incoming event: ' . $event->originalEventNumber() . '@' . $event->originalStreamName() . PHP_EOL;
            echo 'data: ' . ($event->originalEvent() ? $event->originalEvent()->data() : '<null>') . PHP_EOL;
            echo 'retry: ' . $retry . PHP_EOL;
            echo 'no: ' . ++$i . ', elapsed: ' . $stopWatch->elapsed() . PHP_EOL;

            //return new Success();
        },
        function () {
            echo 'dropped' . PHP_EOL;
        },
        10,
        true,
        new UserCredentials('admin', 'changeit')
    );

Above example doesn't return Success. An error should be thrown in such situation because the callback doesn't return a promise.

What happens now is:

Amp\ByteStream\StreamException: The stream was closed by the peer

/app/vendor/amphp/byte-stream/lib/ResourceOutputStream.php:178
/app/vendor/amphp/byte-stream/lib/ResourceOutputStream.php:141
/app/vendor/amphp/socket/src/Socket.php:69
/app/vendor/prooph/event-store-client/src/Transport/Tcp/TcpPackageConnection.php:171
/app/vendor/amphp/amp/lib/Coroutine.php:39
/app/vendor/amphp/amp/lib/Loop/Driver.php:119
/app/vendor/amphp/amp/lib/Loop/Driver.php:70
/app/vendor/amphp/amp/lib/Loop.php:76
/app/src/Subscription/TcpCompetingConsumer.php:121
/app/tests/Subscription/TcpCompetingConsumerTest.php:224

Because the server will not send the heartbeat response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants