Skip to content

Conversation

@jsor
Copy link
Member

@jsor jsor commented Mar 17, 2017

Note: this patch is for 2.x

This rounds up #71 preventing circular references not only when promises are resolved directly with itself but also when promises are resolved with promises which follow itself.

Currently, the following ends in an infinite loop:

$d1 = new \React\Promise\Deferred();
$d2 = new \React\Promise\Deferred();

$d1->resolve($d2->promise());
$d2->resolve($d1->promise());

$d2->promise()
    ->otherwise(function(\LogicException $e) {
        assert('Cannot resolve a promise with itself.' === $e->getMessage());
    })
;

See also the Travis build for the first commit (3524ed7) of this PR adding only a test case.

@jsor jsor requested review from WyriHaximus and clue March 17, 2017 12:23
@jsor jsor changed the title 2.x circular references following promise Fix circular references when resolving with a promise which follows itself Mar 20, 2017
@jsor jsor force-pushed the 2.x-circular-references-following-promise branch from 66c083c to 28b5600 Compare March 20, 2017 07:35
@jsor
Copy link
Member Author

jsor commented Mar 25, 2017

Ping @clue

@jsor jsor merged commit c97ceb3 into 2.x Mar 25, 2017
@jsor jsor deleted the 2.x-circular-references-following-promise branch March 25, 2017 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants