Forms service gotcha: if you try to redirect the client on a succesful form service operation, you need to wrap rfe/push-state in e/drain, otherwise the unserializable routing result tries to transfer to server and causes a Reactor Failure:
(e/defn EditAccountOp [!errors account-uuid account-data]
(e/server
(let [user-ent (d/entity *db [:id *user-id])
account-ent (d/entity *db [:id account-uuid])
rx (e/Offload
(e/Snapshot
#(forms/try-ok
(throw (Exception. "test errors"))
(let [rx (api.account/update-account!
{:acl *acl :conn *conn}
user-ent account-ent
account-data)]
(prn 'rx rx)
rx))))
success? (= [::forms/ok] rx)]
(e/client
(if success?
(e/drain ; if you don't drain here, Electric will complain about unserializable routing result from rfe/push-state.
(reset! !errors nil)
(rfe/push-state ::layout/accounts {}))
(reset! !errors "error!")))
rx)))
Also note I'm having to pass in an !errors atom because there doesn't seem to be a good way to get at the result of the server-side operations (which can return validation errors for many fields), so I can pass them down into Input! fields for showing field-specific errors. Perhaps a :Transact handler or :Result along with :Parse?2nd Update: I restarted my REPL & Electric, and now it's fast again 😕. dev-time memory leak?
We are seeing very slow rendering times when navigating away from an edit form with 15 fields (and their associated layout elements) to a list of DB entries due to the dismount time of form fields. I debugged this with @xifi and confirmed that if we hide the form fields and navigate, the render is instant.
We're displaying a table of accounts. We checked that the Datomic d/pull-many takes 0.5ms itself. The table thead & tfoot render instantly, but the e/for over accounts collection, blocks for several seconds while the form fields from the previous route are unmounted. We cannot see why the e/for would block, other than for dismount.
Is there any fix on horizon to speed up dismount, or avoid new route blocking on previous route's unmount?
We could do a workaround where form is always present but hidden, but we'd have to combine our listing vs editing routes, which muddies concerns.
Update: weirdly, the delay only seems to occur when we navigate the user via rfe/push-href, not when viewing the form and clicking on a list route nav link directly. This suggests something is blocking when it shouldn't.
Do you have browser developer tools open when this happens? Does it happen if you close them? I've had delays like this that seemed to only happen with Chrome Dev Tools open.
By "like this" I mean that they happened on dismount too
@petrus ^
also, please confirm which ns the rfe ns alias resolves to
rfe = reitit.frontend.easy we are using reitit for routing, not HF router
please confirm that you experience broadly degraded electric dispose perf when using RFE router ops and do not experience degraded perf otherwise? This is a huge hint if so
I probably did. Will check.
I can confirm that dismount takes a very long time, around 2.5-3 seconds for a form with 15 fields (~60-80 HTML elements). Closing Chrome Dev tools cuts that time in half, but the delay is still noticeable. I changed navigation to hiding instead of dismounting, to get around this.
> Update: weirdly, the delay only seems to occur when we navigate the user via rfe/push-href, not when viewing the form and clicking on a list route nav link directly. Just to confirm - you're saying that you observe degraded electric performance generally in connection with the hyperfiddle router operators? And when the hyperfiddle router is not in use, you do not experience degraded electric performance?
i'm also using reitit for routing and seeing a delay when unmounting
https://clojurians.slack.com/archives/C7Q9GSHFV/p1762961374637739 should improve overall mount/unmount speed, especially for forms.