From ca08579d47cee4f990a413582274c2af05cf113b Mon Sep 17 00:00:00 2001 From: rcmerci Date: Mon, 4 May 2026 22:43:49 +0800 Subject: [PATCH] enhance(cli): increase timeout for 'sync upload' --- src/main/logseq/cli/command/sync.cljs | 11 +++++++++-- src/test/logseq/cli/command/sync_test.cljs | 14 ++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/logseq/cli/command/sync.cljs b/src/main/logseq/cli/command/sync.cljs index 44ad966d15..6dbde7b11b 100644 --- a/src/main/logseq/cli/command/sync.cljs +++ b/src/main/logseq/cli/command/sync.cljs @@ -83,6 +83,7 @@ (def ^:private sync-start-timeout-ms 10000) (def ^:private sync-start-poll-interval-ms 1000) +(def ^:private sync-upload-timeout-ms (* 30 60 1000)) (def ^:private sync-download-timeout-ms (* 30 60 1000)) (def ^:private sync-start-skipped-states @@ -133,6 +134,11 @@ (when (seq (some-> line str string/trim)) (println line))) +(defn- sync-upload-invoke-config + [cfg] + (assoc cfg :timeout-ms (max 0 (or (:sync-upload-timeout-ms cfg) + sync-upload-timeout-ms)))) + (defn- sync-download-invoke-config [cfg] (assoc cfg :timeout-ms (max 0 (or (:sync-download-timeout-ms cfg) @@ -580,9 +586,10 @@ (defn- execute-sync-upload [action config] (-> (p/let [cfg (cli-server/ensure-server! config (:repo action)) + upload-cfg (sync-upload-invoke-config cfg) _ ( (p/with-redefs [cli-server/ensure-server! (fn [config repo] (swap! ensure-calls conj [config repo]) (p/resolved (assoc config :base-url "http://example"))) - transport/invoke (fn [_ method args] + transport/invoke (fn [cfg method args] (swap! invoke-calls conj [method args]) + (swap! invoke-timeouts conj [method (:timeout-ms cfg)]) (p/resolved {:ok true}))] (p/let [_ (execute-with-runtime-auth {:type :sync-upload :repo "logseq_db_demo"} - {:root-dir "/tmp"})] + {:root-dir "/tmp" + :timeout-ms 10000})] (is (= [[{:root-dir "/tmp" + :timeout-ms 10000 :id-token "runtime-token"} "logseq_db_demo"]] @ensure-calls)) @@ -654,7 +658,9 @@ :http-base nil}]] (second @invoke-calls))) (is (= [:thread-api/db-sync-upload-graph ["logseq_db_demo"]] - (nth @invoke-calls 2))))) + (nth @invoke-calls 2))) + (is (= [:thread-api/db-sync-upload-graph 1800000] + (nth @invoke-timeouts 2))))) (p/catch (fn [e] (is false (str "unexpected error: " e)))) (p/finally done)))))