diff --git a/src/pocketmine/scheduler/TaskScheduler.php b/src/pocketmine/scheduler/TaskScheduler.php index 618bb0110..a641aa292 100644 --- a/src/pocketmine/scheduler/TaskScheduler.php +++ b/src/pocketmine/scheduler/TaskScheduler.php @@ -198,19 +198,26 @@ class TaskScheduler{ unset($this->tasks[$task->getTaskId()]); continue; } + $crashed = false; try{ $task->run($this->currentTick); }catch(\Throwable $e){ + $crashed = true; $this->logger->critical("Could not execute task " . $task->getTaskName() . ": " . $e->getMessage()); $this->logger->logException($e); } if($task->isRepeating()){ - $task->setNextRun($this->currentTick + $task->getPeriod()); - $this->queue->insert($task, $this->currentTick + $task->getPeriod()); - }else{ - $task->remove(); - unset($this->tasks[$task->getTaskId()]); + if($crashed){ + $this->logger->debug("Dropping repeating task " . $task->getTaskName() . " due to exceptions thrown while running"); + }else{ + $task->setNextRun($this->currentTick + $task->getPeriod()); + $this->queue->insert($task, $this->currentTick + $task->getPeriod()); + continue; + } } + + $task->remove(); + unset($this->tasks[$task->getTaskId()]); } }