From f9b8b17ff68e5e1cd0ecbcaa307644c4038bdafc Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 20 Mar 2015 16:07:54 -0700 Subject: [PATCH] [Persistence] Break promise cycle Break cyclical dependency in Promises that was causing persistence to fall into an unresolvable state after overwrite, WTD-1033. --- .../persistence/queue/src/PersistenceFailureHandler.js | 8 ++++++-- platform/persistence/queue/src/PersistenceQueueHandler.js | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/persistence/queue/src/PersistenceFailureHandler.js b/platform/persistence/queue/src/PersistenceFailureHandler.js index 449c1757d2..3efde3d195 100644 --- a/platform/persistence/queue/src/PersistenceFailureHandler.js +++ b/platform/persistence/queue/src/PersistenceFailureHandler.js @@ -18,8 +18,12 @@ define( function persist(failure) { var decoratedPersistence = failure.domainObject.getCapability('persistence'); - return decoratedPersistence && - decoratedPersistence.persist(); + // Note that we issue the persist request here, but don't + // return it. We trust that the PersistenceQueue will + // behave correctly on the next round of flushing. + if (decoratedPersistence) { + decoratedPersistence.persist(); + } } // Retry persistence (overwrite) for this set of failed attempts diff --git a/platform/persistence/queue/src/PersistenceQueueHandler.js b/platform/persistence/queue/src/PersistenceQueueHandler.js index ae717b3cb0..09976b7ff0 100644 --- a/platform/persistence/queue/src/PersistenceQueueHandler.js +++ b/platform/persistence/queue/src/PersistenceQueueHandler.js @@ -50,7 +50,8 @@ define( // Handle any failures from the full operation function handleFailure(value) { return failures.length > 0 ? - failureHandler.handle(failures) : value; + failureHandler.handle(failures) : + value; } // Try to persist everything, then handle any failures