diff --git a/src/Swoole/SwooleTaskDispatcher.php b/src/Swoole/SwooleTaskDispatcher.php index db1b251c2..2363a1568 100644 --- a/src/Swoole/SwooleTaskDispatcher.php +++ b/src/Swoole/SwooleTaskDispatcher.php @@ -43,11 +43,15 @@ public function resolve(array $tasks, int $waitMilliseconds = 3000): array $i = 0; foreach ($tasks as $key => $task) { - if ($results[$i] instanceof TaskExceptionResult) { - throw $results[$i]->getOriginal(); - } + if (isset($results[$i])) { + if ($results[$i] instanceof TaskExceptionResult) { + throw $results[$i]->getOriginal(); + } - $tasks[$key] = isset($results[$i]) ? $results[$i]->result : false; + $tasks[$key] = $results[$i]->result; + } else { + $tasks[$key] = false; + } $i++; }