diff --git a/frontend/src/app/main/errors.cljs b/frontend/src/app/main/errors.cljs index 8e93c9b1a7..b79f1160e7 100644 --- a/frontend/src/app/main/errors.cljs +++ b/frontend/src/app/main/errors.cljs @@ -438,10 +438,10 @@ (volatile! 0)) (defn on-update-loop - "Handler for the rumext update scheduler trips: logs and reports the - throttled update loop with the events being processed, at most once per - `report-window-ms`. Runs inside store watchers and effect bodies, so it - never throws." + "Handler for the rumext update scheduler trips: logs the throttled + update loop and reports it as an unhandled exception with the events + being processed, at most once per `report-window-ms`. Runs inside store + watchers and effect bodies, so it never throws." [{:keys [rounds]}] (try (let [now (inst-ms (ct/now))] @@ -456,9 +456,11 @@ (into-array (map ptk/repr-event events))) (when (seq events) (.set in-flight-by-cause cause (in-flight-lines events))) - ;; Report outside the loop that tripped the scheduler + ;; Report outside the loop that tripped the scheduler, as an + ;; unhandled exception: a throttled loop is an application defect, + ;; so it must reach the error reports and alerts, not only audit. (ts/schedule - #(submit-report :event-name "handled-exception" + #(submit-report :event-name "unhandled-exception" :hint (ex-message cause) :report (fn [] (generate-report cause)) :cause cause))))) diff --git a/frontend/test/frontend_tests/main_errors_test.cljs b/frontend/test/frontend_tests/main_errors_test.cljs index 6bf9276a62..32898be282 100644 --- a/frontend/test/frontend_tests/main_errors_test.cljs +++ b/frontend/test/frontend_tests/main_errors_test.cljs @@ -15,7 +15,7 @@ store was processing when it caught the exception; a failing stream pipeline lists the emitters of the value, not its own event - on-update-loop – never throws into the scheduler's caller; - reports the throttled loop with the events in flight + reports the throttled loop as unhandled, with the events in flight - flash schedules async report and toast – neither the report nor ntf/show is emitted synchronously - organization SSO recovery – expired SSO sessions go back to the provider @@ -572,7 +572,9 @@ (errors/on-update-loop {:rounds 26}) (t/is (= 1 (count @events))) (let [props (deref (first @events))] - (t/is (= "handled-exception" (::ev/name props))) + ;; An unhandled report: it reaches the error reports and alerts, + ;; not only the audit log. + (t/is (= "unhandled-exception" (::ev/name props))) (t/is (= "update loop throttled" (:hint props))) (t/is (str/includes? (in-flight-section (:report props)) "test-update-loop-source")))))))