Skip to content

Commit 99d94e1

Browse files
amabluea-maurice
authored andcommitted
Fixed the lifetime of the ValueEventRegistration that is associated with
Transactions. Transactions that required multiple attempts to commit their changes were seeing a crash because the registration was being cleaned up before the events were posted, resulting in a call to an object that had already been deleted. PiperOrigin-RevId: 264777902
1 parent 30b698b commit 99d94e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

database/src/desktop/core/repo.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,6 @@ void Repo::HandleTransactionResponse(const connection::ResponsePtr& ptr) {
858858

859859
futures_to_complete.push_back(FutureToComplete(
860860
transaction, transaction->current_output_snapshot_resolved));
861-
862-
RemoveEventCallback(transaction->outstanding_listener.get(),
863-
QuerySpec(path));
864861
}
865862

866863
// Now remove the completed transactions.
@@ -881,6 +878,9 @@ void Repo::HandleTransactionResponse(const connection::ResponsePtr& ptr) {
881878
database_, node, QuerySpec(transaction->path)));
882879
transaction->ref_future->CompleteWithResult(transaction->future_handle,
883880
kErrorNone, snapshot);
881+
882+
RemoveEventCallback(transaction->outstanding_listener.get(),
883+
QuerySpec(path));
884884
}
885885
} else {
886886
// Transactions are no longer sent. Update their status appropriately.

0 commit comments

Comments
 (0)