Fork me on GitHub
#re-frame
<
2024-02-22
>
lilactown17:02:51

When an error occurs in a re-frame sub, it often crashes the app; e.g. a common one is we call (sort-by (comp str/lower-case :name) ,,,) in a sub when sometimes it occurs that :name is nil. often the stack trace will bottom out somewhere in clojure.core or re-frame, and not point at the particular subscription function which actually caused the crash. anyone figured out a way to capture these errors in a way that links it back to the particular subscription that failed?

p-himik23:02:01

I see the component that ended up derefing that sub - that's pretty much always enough. Although I agree that seeing the sub itself would be more useful.

p-himik23:02:44

Ah, hold on - I see the component in a stacktrace made by React. The original stacktrace does show the exact location.

p-himik23:02:46

Clicking on the link navigates me to the exact line where I put a throw. And I haven't made any special setup to make it work.

p-himik23:02:36

Just tried with a sub that gets used only as a signal - same result, everything's perfectly clear.

lilactown17:02:41

hmm, could be an issue with how we're using using reagent with hooks then- we have a use-reaction hook that we use with helix that uses a combo of useSubscription + run-in-reaction to replicate the behavior of derefing inside a reagent component. I'll look further into that.