Closed
Description
What should the following code return?
$promise = async(static function (): int {
try {
await(React\Promise\Timer\sleep(2));
} catch (Exception $e) {
return 1;
}
return 2;
})();
$promise->cancel();
var_dump(await($promise));
At the moment, the code would print 1
. The same cancellation logic is triggered for fibers (#20) and coroutines (#13). Accordingly, this affects Async v3 and Async v4.
Perhaps we should reject the entire promise? (See also reactphp/promise#56 for discussion about cancellation semantics in Promise v3).