diff --git a/src/Raven.Client/Documents/BulkInsert/BulkInsertOperation.cs b/src/Raven.Client/Documents/BulkInsert/BulkInsertOperation.cs index 00e278343b16..b1c04a054705 100644 --- a/src/Raven.Client/Documents/BulkInsert/BulkInsertOperation.cs +++ b/src/Raven.Client/Documents/BulkInsert/BulkInsertOperation.cs @@ -317,14 +317,14 @@ private static void HandleHeartbeat(object state) private async Task SendHeartBeatAsync() { - try - { - if (DateTime.UtcNow.Ticks - _lastWriteToStream.Ticks < _heartbeatCheckInterval.Ticks) - return; + if (DateTime.UtcNow.Ticks - _lastWriteToStream.Ticks < _heartbeatCheckInterval.Ticks) + return; - if (_streamLock.Wait(0) == false) - return; // if locked we are already writing + if (_streamLock.Wait(0) == false) + return; // if locked we are already writing + try + { await ExecuteBeforeStore().ConfigureAwait(false); EndPreviousCommandIfNeeded(); _options.ForTestingPurposes?.OnSendHeartBeat_DoBulkStore?.Invoke();