From dda7c5e0f850d3be3d7903de6eb02efebdc501f8 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Wed, 10 Oct 2018 10:24:35 +0200 Subject: [PATCH] Dont kill task worker on exceptions Signed-off-by: Andrea Maria Piana --- src/status_im/utils/async.cljs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/status_im/utils/async.cljs b/src/status_im/utils/async.cljs index 248f52faa4..c46845ddb6 100644 --- a/src/status_im/utils/async.cljs +++ b/src/status_im/utils/async.cljs @@ -1,6 +1,7 @@ (ns status-im.utils.async "Utility namespace containing `core.async` helper constructs" (:require [cljs.core.async :as async] + [taoensso.timbre :as log] [status-im.utils.utils :as utils])) (defn timeout [ms] @@ -8,6 +9,15 @@ (utils/set-timeout (fn [] (async/close! c)) ms) c)) +;; This wrapping is required as core.async macro replaces tries and catch with +;; https://github.com/clojure/core.async/blob/18d2f903b169c681ed008dd9545dc33458604b89/src/main/clojure/cljs/core/async/impl/ioc_helpers.cljs#L74 +;; and this does not seem to play nice with desktop, and the error is bubble up killing the go-loop +(defn run-task [f] + (try + (f) + (catch :default e + (log/error "failed to run task" e)))) + (defn chunked-pipe! "Connects input channel to the output channel with time-based chunking. `flush-time` parameter decides for how long we are waiting to accumulate @@ -37,6 +47,6 @@ [& args] (let [task-queue (apply async/chan args)] (async/go-loop [task-fn (async/