From 703d7bc2e0bf91e7b495ce85be3529b6d881eeb6 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Fri, 19 Feb 2016 13:24:04 -0800 Subject: [PATCH] fix(transaction): Trigger changes only after COMMIT has been executed - Fixes #1327 - This caused the dataase query inside QuerySubscription to, on occassion, return stale results from the database because the database hadn't finished writing. This consequently caused the QuerySubscription to build and incorrect result set. --- src/flux/stores/database-transaction.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/flux/stores/database-transaction.coffee b/src/flux/stores/database-transaction.coffee index 569e8a8ee..880892980 100644 --- a/src/flux/stores/database-transaction.coffee +++ b/src/flux/stores/database-transaction.coffee @@ -27,11 +27,11 @@ class DatabaseTransaction fn(@) .finally => if @_opened - @_query("COMMIT") @_opened = false - global.setImmediate => - for record in @_changeRecords - @database.accumulateAndTrigger(record) + @_query("COMMIT") + .then => + for record in @_changeRecords + @database.accumulateAndTrigger(record) # Mutating the Database