1
0
mirror of https://github.com/danog/amp.git synced 2024-12-02 09:27:46 +01:00

Fix circular reference on exceptions

Fixes #394.
This commit is contained in:
Niklas Keller 2022-07-12 00:15:19 +02:00
parent 41764f01ef
commit e56a64d688

View File

@ -22,10 +22,19 @@ function async(\Closure $closure, mixed ...$args): Future
static $run = null;
$run ??= static function (FutureState $state, \Closure $closure, array $args): void {
$s = $state;
$state = null;
$c = $closure;
$closure = null;
$a = $args;
$args = null;
try {
$state->complete($closure(...$args));
$s->complete($c(...$a));
} catch (\Throwable $exception) {
$state->error($exception);
$s->error($exception);
}
};