shadow-cljs

Joseph Graham 2025-02-24T11:30:59.496109Z

When I start my shadow-cljs repl with CIDER and go to localhost:8080 as it says, the html page displayed is from a completely different project from a different git repo. I have tried everything, even rebooting, but it still insists on using the wrong code. Also, there's a message at the bottom of the screen about Stale Output.

thheller 2025-02-24T11:52:28.440369Z

change the port in shadow-cljs.edn (assuming you are using :dev-http) and try localhost:8080 and the new one

thheller 2025-02-24T11:53:19.213379Z

dunno what your setup is like, so can't suggest much else

Joseph Graham 2025-02-24T12:20:57.122859Z

wow, that fixed it!

Joseph Graham 2025-02-24T12:21:56.719869Z

no wait, it shows the correct code but still has a banner about stale output

thheller 2025-02-24T12:22:25.834569Z

I assume the watch is actually running?

Joseph Graham 2025-02-24T12:23:06.670529Z

well when I type anything in the repl is sais "No available JS runtime".

thheller 2025-02-24T12:23:58.984889Z

yes, stale code means the connection didn't work. this usually means that the JS you have loaded in the browser was not created by the shadow-cljs instance currently running

thheller 2025-02-24T12:24:44.757439Z

which in the past could be caused by running shadow-cljs twice in the same project, but I added a check for that. if you are on an older version this check might not exist

Joseph Graham 2025-02-24T12:25:43.596679Z

hm I'm on 2.28.21

thheller 2025-02-24T12:26:27.992579Z

that definitely has that check, but I'm assuming you are not starting it twice anyway 😛

Joseph Graham 2025-02-24T12:27:15.788179Z

not unless CIDER is

thheller 2025-02-24T12:27:17.811139Z

I do not know enough about your setup to really comment further. just guessing here.

thheller 2025-02-24T12:30:26.504079Z

all the parts involved are shadow-cljs creating .js files on disk, a http server serving a folder over http and a secondary http server by shadow-cljs the generated JS wants to talk to over websocket. not much involved, so not many things to check really.

thheller 2025-02-24T12:31:09.054019Z

but you could have created some kind of abomination setup that doesn't use any of these things and makes everything custom. I wouldn't know 😛

Joseph Graham 2025-02-24T12:35:13.614999Z

I did the tictactoe tutorial and then started to add reitit to it for routing: https://replicant.fun/tutorials/tic-tac-toe/ At some point it worked but apparently something happened a few hours ago. I did have another repl running for plain Java clojure on another project. But that was definitely not shadow-cljs.

thheller 2025-02-24T12:35:53.118729Z

so what is your current config? shadow-cljs.edn I mean

Joseph Graham 2025-02-24T12:37:00.870879Z

{:deps {}
 
 :dev-http {8085 ["resources/public" "classpath:public"]}
 :builds
 {:app
  {:target :browser
   :modules {:main {:init-fn tic-tac-toe.core/main}}
   :dev {:output-dir "resources/public/app-js"}}

  :portfolio
  {:target :browser
   :modules {:main {:init-fn tic-tac-toe.scenes/main}}
   :dev {:output-dir "resources/public/portfolio-js"}}}}

thheller 2025-02-24T12:37:47.840179Z

what is the output you get when you run npx shadow-cljs watch app portfolio in the terminal. so no cider involved?

Joseph Graham 2025-02-24T12:38:04.335089Z

if I run this on command-line it appears to work correctly:

npx shadow-cljs watch app portfolio
In this case it has watches for both app and portfolio. But this morning it worked with just watching portfolio.

thheller 2025-02-24T12:38:42.840259Z

well if you only watch the portfolio build but load the app output in the browser that will give you a stale warning, because that watch isn't running?

Joseph Graham 2025-02-24T12:42:42.147319Z

OK that makes sense. I still have some errors on my other project but that is probably something else.

Joseph Graham 2025-02-24T12:44:07.753879Z

the only reason I started up a repl in this project was to find out if shadow-cljs was the common problem. I now know it isn't

Joseph Graham 2025-02-24T12:44:49.337639Z

so thanks

Joseph Graham 2025-02-24T12:49:58.458419Z

CIDER doesn't appear to allow me to watch multiple builds so I have no idea how this worked yesturday.

Joseph Graham 2025-02-24T12:50:18.533449Z

maybe I did have two servers running

thheller 2025-02-24T12:52:22.798089Z

you can always start another build from the CLJ REPL or the web interface http://localhost:9630

😯 1
thheller 2025-02-24T12:53:04.269529Z

I don't know exactly how the integration in cider works these days, but I'm assuming they just issue a watch command over the REPL in the same way you could manually

thheller 2025-02-24T12:53:51.895139Z

(shadow/watch :app) if you are in the shadow.user ns, otherwise (shadow.cljs.devtools.api/watch :app)

Joseph Graham 2025-02-24T12:54:02.045549Z

yep I never did it manually it just worked in the past. I guess that's why it's all such a mystery when it broke.

Joseph Graham 2025-02-24T12:54:43.865619Z

also I've never seen that web interface 😮

thheller 2025-02-24T12:56:54.115519Z

try (tap> some-data-structure) anywhere and look at it in Inspect 😉

😯 1
Joseph Graham 2025-02-25T09:06:30.413759Z

This morning I am just getting No available JS runtime. I didn't change anything except reboot and start it back up.

Joseph Graham 2025-02-25T09:08:28.910639Z

oh I fixed it. refresh the page in firefox after a few seconds

thheller 2025-02-25T09:09:17.117379Z

yes, JS runtime here is refering to the browser. so the app needs to be open in the browser and the browser needs to connect back to shadow-cljs, which should happen automatically when the watch is running

👍 1