Closed
Description
In case there's something enqueued that throws, the queue is never drained again if it wasn't empty after throwing.
<?php
require __DIR__ . "/vendor/autoload.php";
use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;
$promiseA = new RejectedPromise(new RuntimeException("A"));
try {
$promiseA->done(null, function ($e) {
$promiseB = new RejectedPromise(new RuntimeException("B"));
$promiseB->then(null, function () {
print "OK" . PHP_EOL;
});
throw $e;
});
} catch (Throwable $e) {
// exception caught
}
$promiseC = new FulfilledPromise("C");
$promiseC->then(function () {
// never executed
print "C" . PHP_EOL;
});
print " -- END -- " . PHP_EOL;
It's a specially crafted example, not sure whether it will ever happen accidentally. #97 mostly solves this, but should probably also trigger fatal errors thrown from callbacks called in Queue::drain()
.