Fork me on GitHub
#shadow-cljs
<
2023-06-08
>
Saket15:06:29

Hey folks, a newb clojurian here. Does anyone here use neovim + conjure setup for cljs development using shadow-cljs? I have been facing a problem where the js namespace is not being found while evaluating the form. Would really appreciate any help.

Saket17:06:38

Figured it out. For those who face the same issue: Apparently, we need to add the clojurescript support to the repl session by evaluating:

(ns my-namespace
  (:require [shadow.cljs.devtools.api :as shadow-api]))

(shadow-api/repl :app) ; Where the `app` is the build-id defined in the shadow-cljs.edn

thheller06:06:29

yeah, the js namespace not being available suggests you are talking to a clojure REPL not clojurescript

thheller06:06:50

I'd expect conjure to have a command to switch too? I don't use it though, so I don't know

2
countgizmo07:06:07

Conjure has a ConjureShadowSelect command. You pass build-id to it and that's it. Worked for me every time 👍

2
Saket19:06:17

Didn't know about ConjureShadowSelect . This is awesome. Thanks @U09UWQCC9

Olical11:06:57

On my phone ATM but there's a wiki page on the conjure repo for this too. Basically tells you about that command so you probably already have everything

Drew Verlee19:06:12

Any gut reactions why moving from shadow-cljs 2.21.0 to 2.22.0 (1 step) would result in the error in the attached file? (it's super long i only looked at the first couple lines which repeat a tone due to a loop, then dive into some react stuff that i don't understand) This error is accompanied by the app being stuck at a loading screen, and so my intuition atm is to reimplement this loading screen in a different way. At one point, a very similar (probably the same) error pointed at this location in our code:

(defn resolve-routes
  "Given a map of {<router-key>, <path-or-data>}, matches paths to handlers."
  [router-paths]
  (p/->> router-paths
         (mapv (fn [[router-key path-or-data]]
                 (if (= :query router-key)
                   [router-key path-or-data]
                   (let [handler-data (match-route router-key path-or-data)
                         handler-data (update handler-data :route-params assoc :handler (:handler handler-data))]
                     (if-let [view-entry (get (:handlers @*index) (:handler handler-data))]
                       (p/let [view-entry (lazy/load-lazy view-entry)
                               view (lazy/load-lazy (:view view-entry))]
                         [router-key
                          (merge handler-data
                                 view-entry
                                 {:view view
                                  :router router-key
                                  :path path-or-data})])
                       (do (log/println :warn "missing handler for route" (:handler handler-data))
                           nil))))))
         (p/all)
         (into {})))
where p/all is [kitchen-async.promise :as p], and i suspect the issue is in how the promise is being handled. Some other observations • The error indicates something is stuck in a loop • the error is saying that were calling apply on something which isn't defined inside the google promise library that was put on a queue... i think. But that's not close enough to the app for me to have any idea whats the right move here. • I assume the most likely commit that result in our app having this hiccup is [ https://github.com/thheller/shadow-cljs/commit/5168aff39ddb21ddc5f6e18828456cc73c216e65 ], a closure compiler+lib bump • my co-worker says it's working in safari but not chrome. (yikes!) • I confirmed it works in firefox, so its likey only in chrome. • this happens on the latest version of kitchen-async

thheller06:06:13

TypeError: Cannot read properties of undefined (reading 'apply') this is basically a nullpointerexception if your are familiar with java

thheller06:06:25

meaning it is trying to call something as a function which is nil

thheller06:06:35

so (something "maybe" "args")

thheller06:06:40

from the code above I cannot tell what that might be but there are various ways something can be nil/undefined

thheller06:06:31

don't get to distracted by the code pointing to something inside closure code, that is only because something being undefined being passed into it and it calling it

thheller06:06:18

the async stacks are sometimes weird. verify that everything is exactly what you think it is

thheller06:06:55

also, look at your code for the cause. I'd say it is extremely unlikely to be shadow/closure

🙏 2