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

[2.x] Only stop loop if a pending promise resolves/rejects #39

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

SimonFrings
Copy link
Member

@SimonFrings SimonFrings commented Mar 21, 2022

This is a backport from #33.

If await() is called and the promise is still pending, it will run the loop and stops it afterwards when the promise resolves/rejects. Without these changes the same thing (only stopping the loop) applies for already resolved promises when calling await(). The loop would be stopped even tho await() never started the loop. This could lead to unwanted behavior (e.g. if there are still operations left that need the loop).

Be aware that if a pending promise resolves, and await() stops the loop, every other operation depending on the loop won't be executed. You need to (re)start the loop manually if you want the remaining operations to finish. This behavior only occurs in v2.x and v3.x of async. I would highly recommend to use v4.x with Fibers (PHP>=8.1) to prevent unwanted behavior like this.

Builds on top of #22.

@WyriHaximus WyriHaximus requested a review from clue March 21, 2022 10:35
@WyriHaximus WyriHaximus added this to the v2.0.0 milestone Mar 21, 2022
@clue clue added the new feature New feature or request label Mar 21, 2022
Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimonFrings Thanks for looking into this and backporting this, changes LGTM! :shipit:

@clue clue merged commit 62f6b0c into reactphp:2.x Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants