diff --git a/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs b/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs index b573c6074..3e052bc8b 100644 --- a/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs +++ b/src/Squidex.Infrastructure.MongoDb/EventStore/MongoEventStore.cs @@ -143,11 +143,6 @@ namespace Squidex.Infrastructure.MongoDb.EventStore await plainCollection.Value.InsertManyAsync(commitsToInsert.Select(x => x.Document), new InsertManyOptions { IsOrdered = false }); notifier.NotifyEventsStored(); - - foreach (var commit in commitsToInsert) - { - commit.Completion.SetResult(true); - } } catch (MongoBulkWriteException ex) { @@ -179,6 +174,13 @@ namespace Squidex.Infrastructure.MongoDb.EventStore commit.Completion.SetException(ex); } } + finally + { + foreach (var commit in commitsToInsert) + { + commit.Completion.TrySetResult(true); + } + } } }