Skip to content

Queue broken when throwing from done() (dev-master only) #102

Closed
@kelunik

Description

@kelunik

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions