Closed jasonjckn closed 4 months ago
the magnitude of the number of "unloading clojure.core" is strange too
i missed the defonce semantics, changing my registry* from defonce to def seems to solve my original problem, TBD. Still don't understand why clojure.core is unloaded so much, but anyways that was tangential.
clojure.core shouldn’t get reloaded. Unless you have it as a file on classpath, and you modify that file?
Can you share the project by any chance? I’d love to look into it
@tonsky so sorry, it's super corporate source code, 100kLOC, can't share it :(
If you have large code bases that you actively work on, it might be worth adding
(alter-var-root (intern 'clojure.core 'before-ns-unload)
(fn [old]
(fn before-ns-unload []
(infof "%s unloading %n..." "clojure.core")
(printf "%s unloading %n..." "clojure.core")
(flush))))
to see if you ever repro.
It prints what namespaces are loaded/unloaded anyways, but no, I haven’t seen it yet. Are you sure you don’t have Clojure sources on the classpath?
is it necessary unload clojure.core, and if so how can I prevent it
The reason I ask, is i'm getting a malli schema error
This is happening because malli allows you to register function objects as schema keys, (e.g.
(m/validate int? 3)
, and by default it registers a schema with keyclojure.core/int?
and value[:fn int?]
. The issue arises ifclojure.core
gets reloaded but not my namespace that constructs the registry, and implicitly depends on clojure.core. e.g.eventually the registry becomes stale in seems, because it's storing an older definition of
int?
from before the clojure.core namespace reload.I confirmed clojure.core is getting reloaded, and it correlates with my exception triggering,
And the exact conditions where clojure.core gets reloaded, I don't yet understand, i can't always reproduce it, it seems if I leave a REPL open for 10 minutes with no activity that causes clojure.core to get unloaded, as far as I can tell.
I tried to do this, to stop the unloading, but it didn't work.