Fork me on GitHub
#shadow-cljs
<
2022-05-24
>
cbc03:05:58

i got that "Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running?" message that seems to be quite common among beginners...

cbc03:05:41

things were working properly for me, and then suddenly i started getting this error message

cbc03:05:44

i didn't know what i changed to cause it, i tried reloading the page, restarting browser, restarting repl, restarting shadow-cljs, restarting my machine

cbc03:05:53

nothing seemed to work

cbc03:05:12

i also tried clearing cookies/localstorage for localhost

cbc03:05:32

one clue was that a private tab DID work

cbc03:05:39

(i'm using brave)

cbc03:05:51

finally i tried deleting the compiled app.js

cbc03:05:06

verified that i got a 404 when i loaded the page

cbc03:05:25

then got shadow-cljs to rebuild it

cbc03:05:31

and now...it works again

cbc03:05:45

anybody have any idea what the problem might have been?

cbc03:05:02

the behavior seems possibly consistent with the page being cached in the browser (and private tabs ignoring the cache?), but i'm still not sure why things were working for several days before i hit this issue

cbc03:05:51

a friend suggested disabling the cache in the developer console:

thheller05:05:40

do you use the built-in :dev-http server or some other http server?

thheller05:05:54

the built-in sets the proper cache headers so this doesn't happen. otherwise it might be cache related

thheller05:05:59

or you might have a service worker

thheller05:05:07

don't know enough about your setup to say more

thheller05:05:24

the problem could also be caused by having shadow-cljs running twice in the same project

thheller05:05:38

basically interfering with each other

cbc06:05:32

i'm using kit, which bundles undertow

cbc06:05:39

now that i think about it, does my caching explanation even make sense? why would deleting app.js even cause a 404 in the console if it was cached?

cbc06:05:50

i don't know what a service worker is

cbc06:05:53

i did check for multiple shadow-cljs since you mentioned that to other people...restarting my machine and starting everything fresh should rule that possibility out

thheller06:05:46

if you don't set your caching headers I don't think any are set by default. which will not be ideal with regards to caching

thheller06:05:23

but the network log should show whether it used a cached version or not

thheller06:05:02

maybe brave does some weird caching on its own. can't really say.

cbc06:05:22

i'm new to all this so i don't know how to check the caching headers in the response, but i'm very curious myself

cbc06:05:48

presumably there's some debug option i can set to get kit/undertow to print the response somewhere? (i will look into this more myself when i get a chance)

cbc06:05:28

the network log is a good idea, i'll check that next time i hit this problem

thheller06:05:55

just check the network tab for the request for your .js file

gratitude-thank-you 1
thheller06:05:25

if served via :dev-http it has the Cache-Control: private, no-cache header

thheller06:05:01

and the response will either be a 200 or a 304 not modified

thheller06:05:39

no need to check kit/undertow. the browser network thing will tell you everything you need to know

cbc07:05:37

ahhh, very handy!!

cbc07:05:51

the response doesn't have any cache control headers

cbc07:05:28

btw is it normal to see two of these "remote-relay" requests?

thheller07:05:50

yes, thats the websocket connection for hot-reload/repl

thheller07:05:59

dunno why there is two but one is done so maybe it got reconnected? maybe computer sleep?

cbc07:05:23

ok, i only mentioned it in case it might be related to the issue was having, sounds like it's fine

mjmeintjes10:05:24

I'm getting "No available JS runtime." while developing a file using an :npm-module based build target. The npm module is running in the browser - what is the best way to connect the repl when using :npm-module?

mjmeintjes10:05:07

I think I figured it out, was missing the following:

window["$CLJS"] = require("./npm-module/cljs_env");
require("./npm-module/shadow.cljs.devtools.client.browser");

thheller19:05:11

window["$CLJS"] = require("./npm-module/cljs_env"); this you shouldn't do. it won't work in a release build in case you use it for anything

👍 1
lambdam18:05:54

Hello. I just bumped shadow version from 2.16.6 to 2.19.0 (latest) and get the following error : Caused by: java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()' I looked for it on Google but didn't get anything interesting. Does someone has a clue ? Thanks a lot.

❤️ 1
thheller19:05:46

this is caused by a dependency conflict on the guava dependency. the closure-compiler doesn't properly declare it so it gets messed up

lambdam19:05:36

Oh thanks. I forced guava to the latest version (`31.1-jre`) and it worked. > the closure-compiler doesn't properly declare it so it gets messed up Indeed, I couldn't find guava as a dependency of shadow using clj -X:deps tree | less

Dustin Getz23:05:31

All, fix is to explicitly add

com.google.guava/guava {:mvn/version "31.1-jre"}