From e15f5bb4329592ed22d87cc188a5c4f8c3c7d544 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 23 Feb 2022 12:34:08 +0100 Subject: [PATCH] :bug: Fix issues with not authenticated requests Related to concurrency model refactor. --- backend/src/app/rpc.clj | 18 ++++++++---------- backend/src/app/rpc/retry.clj | 11 ++--------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index 312fa657a..e9ef65a25 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -114,10 +114,7 @@ (if (= :none dname) (with-meta (fn [cfg params] - (try - (p/wrap (f cfg params)) - (catch Throwable cause - (p/rejected cause)))) + (p/do! (f cfg params))) mdata) (let [executor (get executors dname)] @@ -173,13 +170,14 @@ (fn [{:keys [::request] :as params}] ;; Raise authentication error when rpc method requires auth but ;; no profile-id is found in the request. - (when (and auth? (not (uuid? (:profile-id params)))) - (ex/raise :type :authentication - :code :authentication-required - :hint "authentication required for this endpoint")) + (p/do! + (if (and auth? (not (uuid? (:profile-id params)))) + (ex/raise :type :authentication + :code :authentication-required + :hint "authentication required for this endpoint") + (let [params (us/conform spec (dissoc params ::request))] + (f cfg (assoc params ::request request)))))) - (let [params (us/conform spec (dissoc params ::request))] - (f cfg (assoc params ::request request)))) mdata))) (defn- process-method diff --git a/backend/src/app/rpc/retry.clj b/backend/src/app/rpc/retry.clj index f63cb90d9..471bc526d 100644 --- a/backend/src/app/rpc/retry.clj +++ b/backend/src/app/rpc/retry.clj @@ -29,17 +29,10 @@ (if-let [max-retries (::max-retries mdata)] (fn [cfg params] (letfn [(run [retry] - (prn "wrap-retry" "run" retry) - (try - (-> (f cfg params) - (p/catch (partial handle-error retry))) - (catch Throwable cause - (prn cause) - (throw cause)))) - + (-> (f cfg params) + (p/catch (partial handle-error retry)))) (handle-error [retry cause] - (prn "FOOFOFOF" retry (matches cause)) (if (matches cause) (let [current-retry (inc retry)] (l/trace :hint "running retry algorithm" :retry current-retry)