Fix OM 862 - Race condition between schedule-render! and send cb's reconcile! that prevents some future reconciling #863
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Fixes GH-862.
Right now, this block of code can result in a race condition that can stop future reconciling from occurring. Block of code inlined next for convenience:
([resp query remote] (when-not (nil? remote) (p/queue! this (keys resp) remote)) (merge! this resp query remote) (p/reconcile! this remote))))))))In particular,
(merge! ...)will cause a state change that can trigger a(schedule-render! ...)and therefore eventually a reconcile. In cases where therequestAnimationFrameimmediately runs the scheduled reconcile, "eventually" becomes "immediately." During this immediate reconcile, the following line will set:queuedtofalse:In this scenario, the last
(p/reconcile! this remote)in the code block above will run right after the reconcile triggered byrequestAnimationFrame. This reconcile will also call the following line:which will set
:queuedback totrue, without adding enqueueing anything to:queue-remoteor:queue.This puts our reconciler into a state in which subsequent calls to
schedule-render!will think that there is already a render scheduled and won't queue a render and reconcile.where
p/schedule-render!is defined as follows:This means that any reconciles that would result from a change in our reconciler
:statewon't trigger a reconcile. See here:And the symptom will be observed state changes not re-rendering our ui.