diff --git a/src/workflow/Aevatar.Workflow.Infrastructure/Workflows/FileBackedWorkflowCatalogPort.cs b/src/workflow/Aevatar.Workflow.Infrastructure/Workflows/FileBackedWorkflowCatalogPort.cs index 5b275bcf6..a9580b297 100644 --- a/src/workflow/Aevatar.Workflow.Infrastructure/Workflows/FileBackedWorkflowCatalogPort.cs +++ b/src/workflow/Aevatar.Workflow.Infrastructure/Workflows/FileBackedWorkflowCatalogPort.cs @@ -279,11 +279,11 @@ private async Task WaitForCommittedBindAsync( string actorId, CancellationToken ct) { - using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(ct); - timeoutCts.CancelAfter(_options.BindCommitTimeout); + using var bindTimeoutCts = new CancellationTokenSource(_options.BindCommitTimeout); + using var readCts = CancellationTokenSource.CreateLinkedTokenSource(ct, bindTimeoutCts.Token); try { - await foreach (var observed in sink.ReadAllAsync(timeoutCts.Token)) + await foreach (var observed in sink.ReadAllAsync(readCts.Token)) { if (TryObserveCommittedBind( observed, @@ -296,7 +296,7 @@ private async Task WaitForCommittedBindAsync( } } } - catch (OperationCanceledException ex) when (!ct.IsCancellationRequested && timeoutCts.IsCancellationRequested) + catch (OperationCanceledException ex) when (bindTimeoutCts.IsCancellationRequested) { throw BindNotCommitted(definition, actorId, ex); }