Skip to content

Commit 0e247b0

Browse files
committed
sync_engine.cc: implement the fix
1 parent ae30678 commit 0e247b0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Firestore/core/src/core/sync_engine.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "Firestore/core/src/core/sync_engine.h"
1818

19+
#include <algorithm>
20+
1921
#include "Firestore/core/include/firebase/firestore/firestore_errors.h"
2022
#include "Firestore/core/src/core/sync_engine_callback.h"
2123
#include "Firestore/core/src/core/transaction.h"
@@ -528,8 +530,7 @@ void SyncEngine::UpdateTrackedLimboDocuments(
528530

529531
void SyncEngine::TrackLimboChange(const LimboDocumentChange& limbo_change) {
530532
const DocumentKey& key = limbo_change.key();
531-
if (active_limbo_targets_by_key_.find(key) ==
532-
active_limbo_targets_by_key_.end()) {
533+
if (active_limbo_targets_by_key_.find(key) == active_limbo_targets_by_key_.end() && std::find(enqueued_limbo_resolutions_.begin(), enqueued_limbo_resolutions_.end(), key) == enqueued_limbo_resolutions_.end()) {
533534
LOG_DEBUG("New document in limbo: %s", key.ToString());
534535
enqueued_limbo_resolutions_.push_back(key);
535536
PumpEnqueuedLimboResolutions();
@@ -553,6 +554,11 @@ void SyncEngine::PumpEnqueuedLimboResolutions() {
553554
}
554555

555556
void SyncEngine::RemoveLimboTarget(const DocumentKey& key) {
557+
auto enqueued_it = std::find(enqueued_limbo_resolutions_.begin(), enqueued_limbo_resolutions_.end(), key);
558+
if (enqueued_it != enqueued_limbo_resolutions_.end()) {
559+
enqueued_limbo_resolutions_.erase(enqueued_it);
560+
}
561+
556562
auto it = active_limbo_targets_by_key_.find(key);
557563
if (it == active_limbo_targets_by_key_.end()) {
558564
// This target already got removed, because the query failed.

0 commit comments

Comments
 (0)