diff --git a/apps/server/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs b/apps/server/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs index 6c0fe02ae..d234e15ba 100644 --- a/apps/server/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs +++ b/apps/server/Utilities/AliasVault.WorkerStatus/ServiceExtensions/StatusHostedService.cs @@ -58,14 +58,16 @@ public class StatusHostedService(ILogger> logger, Glob // Start the inner while loop with the second cancellationToken. await ExecuteInnerAsync(stoppingToken); } - catch (OperationCanceledException ex) + catch (OperationCanceledException ex) when (stoppingToken.IsCancellationRequested) { - // Expected so we only log information. + // Genuine host shutdown, exit the loop gracefully. logger.LogInformation(ex, "StatusHostedService<{ServiceType}> is stopping due to a cancellation request.", typeof(T).Name); break; } catch (Exception ex) { + // Any other exception should not break the loop but instead log the error + // and let the restart logic below retry the worker. logger.LogError(ex, "An error occurred in StatusHostedService<{ServiceType}>", typeof(T).Name); } finally diff --git a/apps/server/Utilities/AliasVault.WorkerStatus/StatusWorker.cs b/apps/server/Utilities/AliasVault.WorkerStatus/StatusWorker.cs index a3dfb12a8..996dc9fc1 100644 --- a/apps/server/Utilities/AliasVault.WorkerStatus/StatusWorker.cs +++ b/apps/server/Utilities/AliasVault.WorkerStatus/StatusWorker.cs @@ -65,20 +65,20 @@ public class StatusWorker(ILogger logger, Func