Fixes RecurringHostServices leaking the execution context / ambient scope (#12022)
As timers flow the execution context by default this resulted in the Ambient context scope being shared
This commit is contained in:
@@ -40,7 +40,18 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
|
||||
/// <inheritdoc/>
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_timer = new Timer(ExecuteAsync, null, (int)_delay.TotalMilliseconds, (int)_period.TotalMilliseconds);
|
||||
if (!ExecutionContext.IsFlowSuppressed())
|
||||
{
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
_timer = new Timer(ExecuteAsync, null, (int)_delay.TotalMilliseconds, (int)_period.TotalMilliseconds);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_timer = new Timer(ExecuteAsync, null, (int)_delay.TotalMilliseconds, (int)_period.TotalMilliseconds);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +247,13 @@ namespace Umbraco.Cms.Core.Services.Implement
|
||||
/// </summary>
|
||||
private bool TryDeserializeInstructions(CacheInstruction instruction, out JArray jsonInstructions)
|
||||
{
|
||||
if (instruction.Instructions == null)
|
||||
{
|
||||
_logger.LogError("Failed to deserialize instructions ({DtoId}: 'null').", instruction.Id);
|
||||
jsonInstructions = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
jsonInstructions = JsonConvert.DeserializeObject<JArray>(instruction.Instructions);
|
||||
|
||||
Reference in New Issue
Block a user