Closed Vinai closed 4 years ago
Thanks, can you share the entire form that this failed on?
Okay, it's a little ugly hack. A subscription is called from within an event handler.
(defn- on-listing-page? []
@(re-frame/subscribe [:current-page/on-listing?]))
(reg-event-fx :videos/search
(fn-traced [{:keys [db]} [_ term]]
(cond-> {:db (assoc db :search term)}
(not (on-listing-page?)) (assoc :dispatch [:browser/navigate :content]))))
The [:current-page/on-listing?]
subscription in turn depends on a couple of other subscriptions, in the end all depending only on the app-db state.
Ah, sorry about this. In the meantime, removing the fn-traced
will stop the issue from occurring (but of course you then can't trace the event handler).
Thanks, yes - it was working before I introduced the fn-traced
, so I already "fixed" it back again.
Thanks so much for all your awesome work!
I have the same issue:
Uncaught Error: Assert failed: indent was not correctly replaced for form applications
This is a bug, please report it to https://github.com/Day8/re-frame-debux
(integer? indent)
at debux$common$util$spy_first (util.cljc?rel=1528716662972:343)
at re_frame.core.reg_event_db.call.vec__70642 (events.cljs?rel=1531126466372:31)
at std_interceptors.cljc?rel=1528716659806:115
at re_frame$std_interceptors$db_handler__GT_interceptor_$_db_handler_before (std_interceptors.cljc?rel=1528716659806:111)
at re_frame$interceptor$invoke_interceptor_fn (interceptor.cljc?rel=1528716644162:68)
at re_frame$interceptor$invoke_interceptors (interceptor.cljc?rel=1528716644162:106)
at re_frame$interceptor$execute (interceptor.cljc?rel=1528716644162:199)
at re_frame$events$handle (events.cljc?rel=1528716659235:65)
at re_frame.router.EventQueue.re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1 (router.cljc?rel=1528716659400:178)
at re_frame$router$_process_1st_event_in_queue (router.cljc?rel=1528716659400:84)
at re_frame.router.EventQueue.re_frame$router$IEventQueue$_run_queue$arity$1 (router.cljc?rel=1528716659400:197)
at re_frame$router$_run_queue (router.cljc?rel=1528716659400:86)
at router.cljc?rel=1528716659400:145
at re_frame.router.EventQueue.re_frame$router$IEventQueue$_fsm_trigger$arity$3 (router.cljc?rel=1528716659400:168)
at re_frame$router$_fsm_trigger (router.cljc?rel=1528716659400:80)
at router.cljc?rel=1528716659400:186
It appears to be failing in an event handler, which looks like this:
(rf/reg-event-db :init/success
[db/validate-interceptor]
(fn-traced [db [_ {{:keys [:ef/applications :ef/job-posts :web.session/consent?]} :body :as _response}]]
(log/debug "Loaded" (count job-posts) "job posts")
(cond-> db
(seq applications) (assoc :ef/applications (into [] applications))
(seq job-posts) (assoc :ef/job-posts job-posts)
consent? (assoc :web.session/consent? consent?))))
I see the "Loaded X job posts" in the console, so I'm guessing it's to do with the db that gets returned. The db/validate-interceptor
looks like this:
(defn validate
"Returns nil if the db conforms to the spec, throws an exception otherwise"
[spec db]
(when-let [error (s/explain-data spec db)]
(throw (ex-info (str "DB spec validation failed: " (expound/expound-str spec db)) error))))
(def validate-interceptor (rf/after (partial validate :ef/db)))
The issue appeared when I changed my :init/success
handler from a reg-event-fx
to a reg-event-db
; I don't see the issue when using reg-event-fx
, so that may be a more useful workaround as it allows event tracing.
update: i've seen this with reg-event-fx
as well. not using traced functions is the only solution i know.
Seems to be related to #29. It occurs when I use the cond->
macro.
Confirming that this error disappears after removing/replacing cond->
in fn-trace
.
cond-> is now fixed in master will release soon
The browser console asked me to report this error:
Assert failed: indent was not correctly replaced for form (not (on-listing-page?))