-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLJS function instrumentation is never removed, even after refreshing browser #744
Comments
Thanks for the reproduction. I think this is due to a combination of unstrument not being applied for cljs (on purpose) see: and the instrumented functions being tracked inside of a malli/src/malli/instrument/cljs.cljs Line 5 in 3599fbd
I won't be able to dig into this soon, but I believe changing the Unstrument was removed, as noted in the above commit, because it also led to stale code regarding hot-reloading. |
Oh, but that wouldn't explain why browser refresh doesn't fix things - I think the issue is that the instrumented functions are stored in the compiler state, which happens here: Line 2426 in 49cce6a
and here for metadata declared schemas: malli/src/malli/instrument/cljs.clj Line 39 in 49cce6a
I think the solution will not be such a quick fix as stated in the first comment. This came up in the past
This will require updating the macro to perform this loop malli/src/malli/instrument/cljs.clj Line 94 in 49cce6a
in cljs instead of clj. |
For a quick fix you should be able to use |
I'm using |
I am not a dev machine, so haven't tried it, but wanted to reply. I'm afraid I was mistaken, it looks like Line 2399 in 49cce6a
I think that's the source of the bug. I won't be able to dig in further for at least another week though. However, I think the solution is to have |
@dvingo If I understood this correctly, this might be the fix to our other problem where function identity is broken by the instrumentation wrapping function. A macro might be able to do a better job in instrumenting without changing the original structure too much. Thanks you so much for elaborating on this, I'll try to see if I can come up with something myself. |
Unless I'm confused by what your issue is, I'm not sure the function identity issue can be solved, from the definition of instrumentation: replacing one function with another. Line 2434 in 49cce6a
|
@danielcompton I had some time to look into this. Have a fix here #745 |
@danielcompton I think this can be closed now, right? I just tried to repro again against malli |
I found that once you add instrument a CLJS function with a Malli function schema, the function stays instrumented until the ClojureScript build is restarted (and maybe cleaned).
I've created a minimal reproduction with steps here: https://github.com/danielcompton/quickstart-browser.
I think the issue is that Malli's instrumentation state is being tracked in atoms and isn't being cleaned up when recompiling.
I'm not 100% sure but it feels like this may be unsafe in general with the shared AOT cache: https://clojurescript.org/news/2018-03-28-shared-aot-cache.
The text was updated successfully, but these errors were encountered: