Fork me on GitHub
#shadow-cljs
<
2024-05-08
>
hifumi12302:05:39

Is there a way to deal with eval-compile-warnings when using the Shadow CLJS inspector? I am dealing with a case where a value is produced, but a warning is emitted due to external libraries causing warnings from the CLJS compiler. From the browser console, I see

Uncaught Error: No matching clause: eval-compile-warnings
    <anonymous> inspect.cljs:615
    zB impl.cljs:306
    IB grove.cljs:109
    ...
The function corresponds to inspect-eval-result!

thheller06:05:00

a bug I guess, just needs to be handled in the code

thheller06:05:08

I'll see if I can get that done in a bit

thheller06:05:45

do you know what the warning is? or can you run the same code in REPL?

hifumi12318:05:28

its related to the helix library attempting to extend js/symbol

hifumi12318:05:56

it should be sufficient to (require 'helix.core) in any cljs namespace to trigger the compile warning

3starblaze18:05:14

Any ideas why is my shadow nrepl not working? Details in the thread.

3starblaze18:05:04

I start my build:

(:require
   [shadow.cljs.devtools.api :as shadow-api]
   [shadow.cljs.devtools.server :as shadow-server]
(shadow-server/start! {:cache-root ".shadow-cljs"
                       :http {:port 2345}
                       :nrepl {:port 2346
                               :middleware '[cider.nrepl/cider-middleware]}})
(shadow-api/watch {:build-id :my-app-build,
                   :target :browser,
                   :output-dir "build/frontend/my-app-build/js",
                   :modules
                   {:main
                    {:init-fn my-app-ns/main}}})
I get
shadow-cljs - server version: 2.28.3 running at 
shadow-cljs - nREPL server started on port 2346
[:my-app-build] Configuring build.
[:my-app-build] Compiling ...
[:my-app-build] Build completed. (153 files, 60 compiled, 0 warnings, 5.08s)
:watching
I try to connect to nrepl via cider, the connection was refused. I checked out the ports
user> (-> (sh "netstat" "-tunlp") :out print)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.11:40169        0.0.0.0:*               LISTEN      -
tcp        0      0 :::1234                 :::*                    LISTEN      1/java
tcp        0      0 ::ffff:127.0.0.1:42307  :::*                    LISTEN      1/java
tcp        0      0 :::2345                 :::*                    LISTEN      1/java
tcp        0      0 ::ffff:127.0.0.1:2346   :::*                    LISTEN      1/java
tcp        0      0 ::ffff:127.0.0.1:46231  :::*                    LISTEN      1/java
udp        0      0 127.0.0.11:32960        0.0.0.0:*                           -
Shadow should be listening to port 2346. I can do (shadow-api/repl :my-app-build) and it does work but since I am opening a repl inside a repl I don't get a nice REPL experience and I would like to connect to port 2346 so I get the usual repl experience. I checked out what shadow-api/repl does under the hood and it seems like it doesn't use nrepl (`shadow-api/*nrepl-init*` is nil) and instead uses the runtime.

thheller18:05:20

are you still running inside a container? nrepl by default binds to localhost, which is probably not exposed in the container?

thheller18:05:32

try adding :nrepl {:host "0.0.0.0" :port 2346}

3starblaze18:05:35

Yes, it's still in a container. The 2346 is exposed and I tried connecting to it from outside via cider and tried to do wget localhost:2346 to get some response but my attempts were rejected

thheller18:05:15

I can't really help you with docker setups, way to many configuration options that I'm not familiar with

thheller18:05:43

default is 127.0.0.1, no idea why your above is listing 127.0.0.11. maybe just failed to bind properly at all

3starblaze18:05:14

I think it might be some docker thing, it's not bound to 1/java

3starblaze18:05:58

0.0.0.0 host worked, thanks. It doesn't seem to be cljs repl but that's something I should check out in the docs before bothering you

thheller18:05:23

it always starts CLJ. (shadow/repl :my-app-build) will switch it to CLJS for that build

thheller18:05:44

cider usually does this in some way too, no clue how though

3starblaze18:05:00

Aha, that's it. Thank you for the help.

3starblaze18:05:39

I remember checking out cider preset, in essence it runs shadow/repl before display the repl screen