diff --git a/Conductor/Client/Worker/WorkflowTaskExecutor.cs b/Conductor/Client/Worker/WorkflowTaskExecutor.cs index d7fe4eb8..bdda36a3 100644 --- a/Conductor/Client/Worker/WorkflowTaskExecutor.cs +++ b/Conductor/Client/Worker/WorkflowTaskExecutor.cs @@ -130,18 +130,30 @@ private async void WorkOnce(CancellationToken token) _logger.LogDebug("All workers are busy"); return new List(); } - var tasks = _taskClient.PollTask(_worker.TaskType, _workerSettings.WorkerId, _workerSettings.Domain, availableWorkerCounter); - if (tasks == null) + + try + { + var tasks = _taskClient.PollTask(_worker.TaskType, _workerSettings.WorkerId, _workerSettings.Domain, + availableWorkerCounter); + if (tasks == null) + { + tasks = new List(); + } + + _logger.LogTrace( + $"[{_workerSettings.WorkerId}] Polled {tasks.Count} tasks" + + $", taskType: {_worker.TaskType}" + + $", domain: {_workerSettings.Domain}" + + $", batchSize: {_workerSettings.BatchSize}" + ); + return tasks; + } + catch (Exception e) { - tasks = new List(); + _logger.LogError($"Error polling for {_worker.TaskType}. Error = {e.Message}"); + return new List(); } - _logger.LogTrace( - $"[{_workerSettings.WorkerId}] Polled {tasks.Count} tasks" - + $", taskType: {_worker.TaskType}" - + $", domain: {_workerSettings.Domain}" - + $", batchSize: {_workerSettings.BatchSize}" - ); - return tasks; + } private async void ProcessTasks(List tasks, CancellationToken token)