From 0092806ddaca7b68aaf881769dfb6a0fe042b2d8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 26 Jan 2022 18:09:59 +0100 Subject: [PATCH] :sparkles: Prevent high cpu usage on reporting big errors. --- backend/src/app/http/errors.clj | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index d74d525c6..6efd0e796 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -30,10 +30,13 @@ :method (:request-method request) :hint (ex-message error) :params (:params request) - :spec-problems (some-> data ::s/problems) - :spec-value (some-> data ::s/value) - :spec-explain (with-out-str - (expound/printer data)) + + :spec-problems (some->> data ::s/problems (take 10) seq vec) + :spec-value (some->> data ::s/value) + :spec-explain (binding [s/*explain-out* expound/printer] + (with-out-str + (s/explain-out (update data ::s/problems #(take 10 %))))) + :data (some-> data (dissoc ::s/problems ::s/value :hint)) :ip-addr (parse-client-ip request) :profile-id (:profile-id request)}