Skip to content

Commit

Permalink
Fix fiber reference in error path
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Feb 24, 2022
1 parent accd1fb commit 13ca2ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/EventLoop/Internal/DriverSuspension.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ public function suspend(): mixed
}

$this->pending = true;
$this->suspendedFiber = $fiber;

// Awaiting from within a fiber.
if ($fiber) {
$this->suspendedFiber = $fiber;

try {
return \Fiber::suspend();
} catch (\FiberError $exception) {
Expand All @@ -105,12 +106,14 @@ public function suspend(): mixed
if ($suspensions) {
\gc_collect_cycles();

/** @var self $suspension */
foreach ($suspensions as $suspension) {
if ($suspension->fiber === null) {
$fiber = $suspension->fiberRef?->get();
if ($fiber === null) {
continue;
}

$reflectionFiber = new \ReflectionFiber($suspension->fiber);
$reflectionFiber = new \ReflectionFiber($fiber);
$info .= "\n\n" . $this->formatStacktrace($reflectionFiber->getTrace(\DEBUG_BACKTRACE_IGNORE_ARGS));
}
}
Expand Down

0 comments on commit 13ca2ba

Please sign in to comment.