Fork me on GitHub
#shadow-cljs
<
2021-12-14
>
Jace04:12:23

Could anyone help me out with these errors I'm getting when I run npx shadow-cljs watch :app ? I don't know what they mean or how to fix them.

shadow-cljs - config: C:\Users\JaceMaverick\Downloads\quickstart-browser-master\quickstart-browser-master\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.16.8 running at 
shadow-cljs - nREPL server started on port 55621
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (277 files, 0 compiled, 0 warnings, 4.96s)
Dec 13, 2021 10:00:47 PM io.undertow.server.Connectors executeRootHandler
ERROR: UT005071: Undertow request failed HttpServerExchange{ GET /}
Unexpected error macroexpanding go at (com/wsscode/pathom/connect.cljc:1177:8).
        at clojure.lang.Compiler.macroexpand1(Compiler.java:7023)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7097)
        at clojure.lang.Compiler.analyze(Compiler.java:6793)
        at clojure.lang.Compiler.analyze(Compiler.java:6749)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6122)
        at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6440)
...

thheller06:12:05

@jacemaverick5 I'm guessing you have a conflicting core.async version in your :dependencies? Just remove it shadow-cljs already provides one

thheller06:12:36

otherwise make sure you use the version listed here or newer https://clojars.org/thheller/shadow-cljs

Pepijn de Vos09:12:13

Ohno... what is the proper way to have multiple pages? I've added multiple entries to my script but this seems to break code reload because it calls init on both namespaces

Pepijn de Vos10:12:52

Maybe the proper way is a client side router... I was just trying to have actual separate HTML pages.

kardan10:12:04

@pepijndevos can’t you do multiple builds?

Pepijn de Vos10:12:51

But then I'd have to run multiple watches to develop the app

kardan10:12:58

Yes, that would be required

Pepijn de Vos10:12:06

Ah you can actually just pass multiple builds

Pepijn de Vos10:12:44

It seems like you could also have multiple modules to a build, but this is... confusing

Pepijn de Vos10:12:01

ah I think I figured it out!

Jakub Holý (HolyJak)12:12:11

Is there a command I can run so that all dependencies needed for npx shadow-cljs watch <something> will be downloaded and when I actually run watch, I won't need internet access? 🙏

thheller17:12:37

pretty much all commands will accomplish this assuming you are not using any shapshot dependencies or so

thheller17:12:51

shadow-cljs classpath is probably the "quickest"

thheller17:12:18

also assuming your are using only shadow-cljs.edn and not project.clj/deps.edn

Jakub Holý (HolyJak)18:12:22

But does classpath download also the dev - only dependencies such as Ring?

thheller18:12:02

I don't understand. shadow-cljs has no "dev only" concept at all regarding dependencies?

thheller18:12:33

classpath downloads everything watch or server or anything else would download

Jack Arrington14:12:51

Hi all, I'm a little confused on how shadow-cljs prints certain exceptions. For example, if I evaluate this snippet at the REPL:

(defn greeting-for
   [name]
   {:pre [(string? name)]}
   (str "Hello " name))
(greeting-for 123)
The assert will of course fail, but the only output I get back from the REPL is:
#object[Error Error: Assert failed: (string? name)]
No stack trace, no mention of which function's assert failed. Is there some way to get it to actually display the details of the Error thrown, instead of just its message field?

Jack Arrington16:12:56

I should mention as well, I'm not sure if this is a shadow-cljs-specific issue or just a ClojureScript issue. I can ask in #clojurescript if it's not shadow-cljs related

thheller19:12:39

showing a proper stacktrace is kinda difficult for REPL eval'd code. it should be much better for code loaded from actual files

Jack Arrington20:12:28

I get that the line numbers would be messed up, but is there no way to even show the function names called?

Jack Arrington20:12:37

That alone would be tremendously helpful. Even if it just showed the mangled js-generated function names, that would probably be enough for me to tell where the error is coming from

thheller20:12:39

you can do (js/console.log *e) I guess

thheller20:12:01

or (.-stack *e)

thheller20:12:07

not ideal in either case though

thheller20:12:36

just noticed that (pst) is broken. that is what I'd be using normally

thheller20:12:18

eg.

$ clj
Clojure 1.10.1
(defn greeting-for
   [name]
   {:pre [(string? name)]}
   (str "Hello " name))
#'user/greeting-for
user=> (greeting-for 123)
Execution error (AssertionError) at user/greeting-for (REPL:1).
Assert failed: (string? name)
user=> (pst)
AssertionError Assert failed: (string? name)
        user/greeting-for (NO_SOURCE_FILE:1)
        user/greeting-for (NO_SOURCE_FILE:1)
        user/eval148 (NO_SOURCE_FILE:1)
        user/eval148 (NO_SOURCE_FILE:1)
        clojure.lang.Compiler.eval (Compiler.java:7177)
        clojure.lang.Compiler.eval (Compiler.java:7132)
        clojure.core/eval (core.clj:3214)
        clojure.core/eval (core.clj:3210)
        clojure.main/repl/read-eval-print--9086/fn--9089 (main.clj:437)
        clojure.main/repl/read-eval-print--9086 (main.clj:437)
        clojure.main/repl/fn--9095 (main.clj:458)
        clojure.main/repl (main.clj:458)
nil
user=>

Jack Arrington01:12:37

That is a shame about (pst) being broken, but good tips, thanks!

Jakub Holý (HolyJak)17:12:47

Hi again! I am running npx shadow-cljs watch main and it does compile and prints watching build :main yet the browser says > Stale output! Your loaded JS was not produced by the running shadow-cljs instance. How do I troubleshoot this? (I load the app via the backend server, not shadow dev server) I even deleted the main.js before restarting shadow to make sure that it is built by shadow. Solved: I was starting shadow in the wrong project 😅

1
thheller17:12:54

could be cache? eg. overeager service worker?

thheller17:12:40

also make sure you are actually loading the file you think you are loading. often people change :output-dir but forget to adjust paths in HTML or so

thheller17:12:26

delete the file shadow-cljs is producing and load your page. if you get something then thats not the file you are loading :P

Jakub Holý (HolyJak)17:12:26

Yeah, st. is fishy, when I rm the file and stop shadow, the file does not exist but the server still happily serves it...