diff --git a/src/EventLoop/Internal/DriverSuspension.php b/src/EventLoop/Internal/DriverSuspension.php index 462b612..b8d74ce 100644 --- a/src/EventLoop/Internal/DriverSuspension.php +++ b/src/EventLoop/Internal/DriverSuspension.php @@ -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) { @@ -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)); } }