glimt icon indicating copy to clipboard operation
glimt copied to clipboard

on error transition not invoked

Open nyemiks opened this issue 1 year ago • 0 comments

I have a state machine defined as follows

logInFsm { :id :login-service :http-xhrio { :uri "http://127.0.0.1:8081/crm/api/user-profiles/authenticate" :method :post :params credentials :format (ajax/json-request-format) :response-format (ajax/json-response-format {:keywords? true})
:headers { "userId" "csduser1" "tenantId" "test" "provider" "test" } } :max-retries 5

        :on-success    [::myevent/response "success"]
        :on-error        [::myevent/error-response "error"]
        :on-failure      [::myevent/fail-response "failure"]
        }

The state machine is started as follows

(rf/dispatch [::http/start logInFsm])

When testing, I noticed that if there is an error from the server, the configured on error event is not invoked.

Here is the error log

############################################################

An error occured while handling the re-frame event: [:re-statecharts.core/transition :login-service :glimt.core/error {:response {:result false, :errorCode nil, :errorMsg " unable to execute operation: logIn\n ", :response nil, :errors [" unable to execute operation: logIn"], :xri nil}, :last-method "POST", :last-error " [400]", :failure :error, :status-text "", :status 400, :uri "http://127.0.0.1:8081/crm/api/user-profiles/authenticate", :debug-message "Http response at 400 or 500 level", :last-error-code 6}] Within the :re-statecharts.core/transition event handler function.

router.cljc:201 Uncaught Error: No protocol method IScheduler.schedule defined for type re-statecharts.core/Scheduler: [object Object] at Object.cljs$core$missing_protocol [as missing_protocol] (core.cljs:324:4) at statecharts$delayed$IScheduler$schedule$dyn_34674 (delayed.cljc:5:1) at Object.statecharts$delayed$schedule [as schedule] (delayed.cljc:5:1) at Object.statecharts$impl$execute_internal_action [as execute_internal_action] (impl.cljc:242:8) at eval (impl.cljc:260:21) at eval (core.cljs:2500:21) at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:2500:20) at Object.eval [as cljs$core$IReduce$_reduce$arity$3] (core.cljs:3529:28) at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:2570:17) at Function.eval [as cljs$core$IFn$_invoke$arity$4] (impl.cljc:257:7)

###########################################

It appears there is an uncaught exception which is occuring in the re-statecharts.core library.

I am still new to clojure so I am not at the level where I can make adjustments to underlying libraries.

nyemiks avatar Jun 14 '24 14:06 nyemiks