HumbleUI / HumbleUI

Clojure Desktop UI framework
Apache License 2.0
1.17k stars 44 forks source link

`*window` is `nil` after `cider-connect-clj` and middleware is `cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor` #6

Open rgkirch opened 2 years ago

rgkirch commented 2 years ago

The demo ui with 4 rotating boxes comes up but about a second after I connect with emacs, the app visibly freezes (the boxes stop rotating). I can deref *window and see that it's nil.

$ git diff
diff --git a/deps.edn b/deps.edn
index 2842623..c541b04 100644
--- a/deps.edn
+++ b/deps.edn
@@ -19,4 +19,6 @@

   :dev
   {:extra-paths ["dev"]
-   :extra-deps  {nrepl/nrepl {:mvn/version "0.8.3"}}}}}
\ No newline at end of file
+   :extra-deps {cider/cider-nrepl {:mvn/version "0.25.9"}
+                refactor-nrepl/refactor-nrepl {:mvn/version "3.1.0"}}
+   :main-opts ["-m" "user" "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]}}}
$ clj -A:windows:dev
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.orchard.v0v7v3.orchard.misc, being replaced by: #'refactor-nrepl.inlined-deps.orchard.v0v7v3.orchard.misc/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: refactor-nrepl.inlined-deps.orchard.v0v7v3.orchard.misc, being replaced by: #'refactor-nrepl.inlined-deps.orchard.v0v7v3.orchard.misc/update-keys
nREPL server started on port 54259 on host kubernetes.docker.internal - nrepl://kubernetes.docker.internal:54259
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: cider.nrepl.inlined-deps.orchard.v0v6v5.orchard.misc, being replaced by: #'cider.nrepl.inlined-deps.orchard.v0v6v5.orchard.misc/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: cider.nrepl.inlined-deps.orchard.v0v6v5.orchard.misc, being replaced by: #'cider.nrepl.inlined-deps.orchard.v0v6v5.orchard.misc/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.passes, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.passes.uniquify, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
rgkirch commented 2 years ago

Umm. I the problem goes away if I don't set (setq cljr-warn-on-eval nil).

https://github.com/clojure-emacs/clj-refactor.el#in-case-refactor-nrepl-is-used-for-advanced-ast-based-refactorings

The analyzer refactor-nrepl uses needs to eval the code too in order to be able to build the AST we can work with. If that causes side effects like writing files, opening connections to servers, modifying databases, etc. performing certain refactoring functions on your code will do that, too.

By default the user is warned about this when an AST dependent feature is invoked. If this warning is an annoyance and the project can be evalled without any risks set cljr-warn-on-eval to nil so cljr-eagerly-build-asts-on-startup can take effect.

We create ASTs for all the namespaces at REPL start up if cljr-warn-on-eval is set to nil.

I was reading the docs on clj-refactor since I haven't used it before and I added that to my emacs config today. Interesting.

tonsky commented 2 years ago

Interesting! I have no idea what clj-refactor is or how does it work. If you ever figure out that the problem is or how example should be adjusted to avoid this, let me know