Skip to content

Use fibers instead of stopping the event loop waiting for a response to complete #49

Closed
@WyriHaximus

Description

@WyriHaximus

Description
Currently, the promise object of this package contains a major non-blocking design flaw that stops the loop while waiting for a response to complete: https://github.com/php-http/react-adapter/blob/master/src/Promise.php#L115-L132

Example
When using the upcoming fiber implementation in react/async this design flaw can be turned into a feature and still wait for responses to come in and also keep the event loop running when it does.

Additional context
The v4 version (already usable at ^4@dev) requires PHP 8.1. However we're also preparing a v2 and v3 that provide the same await() method but by using the same technique as the wait method on the promise object as an upgrade path for those that can't upgrade to PHP 8.1 yet.

Would you be open to a PR that implements this? Either directly to 8.1 or with keeping support for older PHP version by using the v2 and v3 packages as well.

P.S. I understand that calling the wait method a design flaw might come over as harsh. But this comes from stopping the loop in a fully non-blocking application is a deadly sin as the application will randomly stop as nothing is expecting this. I also fully understand that this is fine in hybrid applications this is fine or even expected, hence we added v2 and v3 as upgrade path for this situations.

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