 (defn sync-all
   "Wait until all asynchronous server operations have been completed."
   []
-  (recv-and-wait "/synced"))
+  @(recv "/synced"))
 
 ; The /done message just has a single argument:
 ; "/done" "s" <completed-command>

   (let [ctls? (if (or (= 1 ctls?) (= true ctls?)) 1 0)]
     (let [reply-p (recv "/g_queryTree.reply")
           _ (snd "/g_queryTree" id ctls?)
          tree (:args (read-reply reply-p))]
       (with-meta (parse-node-tree tree)
         {:type ::node-tree})))))


  (let [sync-id (rand-int 999999)
        reply-p (recv "/synced")
        _ (snd "/sync" sync-id)
        reply (await-promise reply-p (if timeout timeout REPLY-TIMEOUT))
        reply-id (first (:args reply))]
    (= sync-id reply-id)))

