This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-21
Channels
- # adventofcode (27)
- # announcements (2)
- # babashka (1)
- # beginners (111)
- # calva (11)
- # cider (82)
- # clara (6)
- # clojure (44)
- # clojure-dev (5)
- # clojure-europe (27)
- # clojure-nl (5)
- # clojure-spec (3)
- # clojure-uk (3)
- # clojurescript (29)
- # core-async (5)
- # cursive (4)
- # datalevin (1)
- # datomic (39)
- # exercism (4)
- # figwheel-main (1)
- # fulcro (32)
- # graalvm (7)
- # gratitude (1)
- # integrant (4)
- # jobs (1)
- # lein-figwheel (3)
- # leiningen (4)
- # lsp (3)
- # luminus (3)
- # meander (2)
- # nextjournal (1)
- # off-topic (10)
- # other-languages (26)
- # pathom (14)
- # polylith (9)
- # re-frame (16)
- # remote-jobs (1)
- # shadow-cljs (4)
- # specter (2)
- # sql (6)
- # timbre (2)
- # tools-build (12)
- # xtdb (9)
Hi, my ClojureScript project is failing on Safari when compiled in advanced mode but not when in development. The error is the following which happens in Re-frame:
https://orgpad.com/img/CvLhaSuEpB0LWnDVQDtf8I/download?token=B8H0UoA7tK7Zryuqfuigj-
@pavel.klavik can you share your compiler output? any warnings?
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? NPM dependency "react" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs NPM dependency "react-dom" has installed version "^16.14.0" "16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs [:client] Compiling ... [:client] Build completed. (1220 files, 405 compiled, 0 warnings, 87.43s)
I don't see any reference to intersects
in re-frame's code. it could be an error in one of your handlers
It is likely unrelated to Reframe, it was just also throwing stack traces here as well.
It is bizzare behavior of Safari which somehow changes nil to 0 when passing it into another function. I have no explanation for that.
I often hear people ask about using subscriptions in weird places and then be warned "You can do it, but you will leak subscriptions." And the FAQ https://github.com/day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAJsEvent.md has "might create a memory leak (the subscription might not be "freed". btw, why does it say "might not be freed"? Why the uncertainty? Put another way,how does re-frame know when it can GC subscriptions? I am working on a new r/f project and seeing subscriptions created and immediately deref-ed just to read the app DB, outside the usual view function, and I have to guess these fall in the leaked category. Or might. :) In cases like these, is it better to just access the app DB directly? I do not see a need for reactive data flow, usually: they are just pulling data from static state loaded with the page.
> why does it say "might not be freed"? Why the uncertainty?
Because subscriptions that are used in a reactive context (view functions, reactions, as signals to other subs) will be registered for cache cleanup when their context no longer needs them, via reagent.ratom/add-on-dispose!
. Re-frame code is rather easy to follow here.
> In cases like these, is it better to just access the app DB directly?
If it's something completely outside of a view, then yes - IIRC that's one of the things that re-frame documentation recommends.
If it's something within a view but outside of a reactive context (a JS event handler), then you can simply create and deref such a sub in the view and then use the concrete value to create the JS event handler function.
OK, but in the example from the FAQ, unless I misunderstand, the subscription established by (subscribe [:something])
will never be freed, because the anonymous event handler function is not dynamically in the reactive context. In which case, "might" is the wrong word. Maybe? :thinking_face:
It will never be freed if it's not used in any reactive context. If it's used once and exactly as in the example, it will indeed not be freed.
interesting. does that mean that this lib has a leak in it’s design? https://github.com/gadfly361/re-pressed/blob/master/src/main/re_pressed/impl.cljs#L179