You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider these test cases (the one case immediately resumes in cycle collection, the other schedules something on the event loop):
public function testSuspensionResumptionWithQueueInGarbageCollection(): void
{
$suspension = EventLoop::getSuspension();
$class = new class($suspension) {
public function __construct(public Suspension $suspension) {}
public function __destruct() { $this->suspension->resume(true); }
};
$cycle = [$class, &$cycle];
unset($class, $cycle);
$ended = $suspension->suspend();
$this->assertTrue($ended);
}
public function testEventLoopResumptionWithQueueInGarbageCollection(): void
{
$suspension = EventLoop::getSuspension();
$class = new class($suspension) {
public function __construct(public Suspension $suspension) {}
public function __destruct() { EventLoop::queue($this->suspension->resume(...), true); }
};
$cycle = [$class, &$cycle];
unset($class, $cycle);
$ended = $suspension->suspend();
$this->assertTrue($ended);
}
These cases both will fail with:
Error: Event loop terminated without resuming the current suspension (the cause is either a fiber deadlock, or an incorrectly unreferenced/canceled watcher):
(The trailing colon is also weird, it means that no other fibers exist, maybe write that out.)
I was initially very confused when this happened in my code as dumping the event loop showed a pending queue() call, while the EventLoop reported as finished.
I would expect that, after the gc_collect_cycles():
\gc_collect_cycles(); // Collect any circular references before dumping pending suspensions.
the EventLoop is checked for any active, referenced watchers or microtasks, and if yes, is resumed. Similarly, if a suspension was resumed within that cycle collection, it will leave the code path leading to the error being thrown.
The text was updated successfully, but these errors were encountered:
danog
linked a pull request
Dec 6, 2024
that will
close
this issue
Consider these test cases (the one case immediately resumes in cycle collection, the other schedules something on the event loop):
These cases both will fail with:
(The trailing colon is also weird, it means that no other fibers exist, maybe write that out.)
I was initially very confused when this happened in my code as dumping the event loop showed a pending queue() call, while the EventLoop reported as finished.
I would expect that, after the gc_collect_cycles():
event-loop/src/EventLoop/Internal/DriverSuspension.php
Line 129 in 25de49a
the EventLoop is checked for any active, referenced watchers or microtasks, and if yes, is resumed. Similarly, if a suspension was resumed within that cycle collection, it will leave the code path leading to the error being thrown.
The text was updated successfully, but these errors were encountered: