Skip to content

Using await and returning response as promise does not work #263

@map-g

Description

@map-g

When using React\Async\await somewhere and then returning the response as a promise (e.g. a promise got from React\Http\Browser::get(), in the example it's replaced by a simple resolve($response)), an assertion in the \FrameworkX\Io\FiberHandler (line 49: assert($response instanceof ResponseInterface);) will fail. After removing this assertion it seems to work fine.
Returning the promise without any React\Async\await before does not reveal this.

#!/usr/bin/env php
<?php

declare(strict_types=1);

use function React\Async\await;
use function React\Promise\resolve;
use function React\Promise\Timer\sleep;

require __DIR__ . '/../vendor/autoload.php';

$app = new FrameworkX\App();

$app->get('/', function () {
    await(sleep(3));
    $response = React\Http\Message\Response::plaintext(
        "Hello world!\n",
    );
    return resolve($response);
});

$app->run();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnew featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions