Fork me on GitHub
#shadow-cljs
<
2020-04-30
>
Joel Söderman08:04:12

Regarding running just one test with shadow-cljs. Thanks @wxitb2017 and @thheller for the help yesterday! In the end I built upon with Lucy’s code and added the functionality to provide several substrings that the test is matched against. I put the code in a gist in case it’s of use to someone else: https://gist.github.com/johesoman/16d765d158e0018ed20f9aafc6d4501f

🎉 8
👍 4
knubie15:04:09

@johesoman I made a library awhile ago for running a single test in cljs (with fixtures). Maybe you’ll find it useful? https://github.com/knubie/cljs-run-test

Joel Söderman17:04:51

Very cool! Thanks 🙂

thheller14:05:30

the new shadow-cljs release 2.8.110 adds some options to the :node-test target output

thheller14:05:56

so you can run node out/tests.js --list to see tests it knows

thheller14:05:22

and run a single test via node out/tests.js --test=some.ns/foo

thheller14:05:32

or test a ns via node out/tests --test=some.ns

thheller14:05:44

or multiple via node out/tests.js --test=some.ns,other.ns

thheller14:05:47

more to come

❤️ 8
Joel Söderman14:05:02

Awesome! Thank you for being so responsive 🙂

Chris McCormick11:04:48

what's a good way to diagnose an error that only occurs when --debug is not passed during app release?

yenda11:04:43

tried shadow-cljs check?

thheller12:04:11

likely a externs issue yes

yenda12:04:06

btw why does shadow-cljs check reports cljs.core.PersistentArrayMap expressions are not callable as a warning?

yenda12:04:27

I do that all the time 😄

thheller12:04:58

not sure I know which warning you mean?

thheller12:04:12

check in general reports many false positives and non-issues

thheller12:04:19

that why its not documented anywhere 😛

thheller12:04:32

it can be useful to find issues but its definitely not user friendly

thheller12:04:27

@chris358 --debug also turns on :pseudo-names which still renames everything but uses longer names that are less likely to clash with anything

thheller12:04:58

so if your app has issues without that it is likely that you maybe have something in the page that defines a global variable or so that then clashes with the CLJS code

thheller12:04:43

one common issue in the past for example is google analytics that creates that the closure compiler would also use unless you had externs telling it not to

thheller12:04:00

with :output-wrapper defaulting to true nowadays thats less of an issue

thheller12:04:57

but can still happen. js->clj is also known to cause issues so if you use that with a lot of JS data that can be another cause

Chris McCormick12:04:09

interesting, thanks for the pointers!

Chris McCormick12:04:43

it started happening after i slurped in a few new libraries so a global name clash could indeed be the cause.

pmooser12:04:08

I'm working on my application, using shadow-cljs, with the bootstrap cljs support ... And if I serve the index.html via my own server (instead of the embedded shadow-cljs dev http server), I see an error from (I think) the bootstrap cljs stuff trying to load resources over a websocket. But I can't exactly see what it is trying to do or request - is there any advice on how I should debug this? It's perplexing, but if these resources fail to load, my bootstrap cljs eval stuff stops working.

thheller12:04:09

bootstrap doesn't load anything over websocket

thheller12:04:56

just look at the browser console. it should be making regular XHR requests to get the files.

pmooser12:04:27

I am looking at the console. It isn't totally evident what is being done. Here, for example, is the error from the console:

pmooser12:04:33

Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Transit$JSONUnmarshaller.reader.JSONUnmarshaller.unmarshal (reader.js:39)
    at Transit$Reader.reader.Reader.read (reader.js:59)
    at Object.cognitect$transit$read [as read] (transit.cljs:137)
    at Object.shadow$cljs$bootstrap$browser$transit_read [as transit_read] (browser.cljs:23)
    at .XhrIo.G__63340 (browser.cljs:33)
    at goog.net.XhrIo.goog.events.EventTarget.fireListeners (eventtarget.js:285)
    at Function.goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:383)
    at goog.net.XhrIo.goog.events.EventTarget.dispatchEvent (eventtarget.js:196)
    at .XhrIo.onReadyStateChangeHelper_ (xhrio.js:871)

pmooser12:04:35

Not exactly super clear.

thheller12:04:47

just look at the request it made

thheller12:04:57

and click the url it requested to open in a new tab

thheller12:04:09

it expects a JSON response but likely your server returned HTML instead?

pmooser12:04:38

Ah, no, I think it's because I don't understand the ... I'm not sure the right term, I'm not sure how the paths are constructed.

pmooser12:04:04

And not (for example) js/bootstrap/ ...

pmooser12:04:12

Yes (I am on localhost 8098)

thheller12:04:21

yes the path it requests defaults to /bootstrap

pmooser12:04:30

I don't understand why some requests are /js/... and these are /bootstrap

pmooser12:04:37

Are there any knobs on my end that can control that?

thheller12:04:56

you can configure the path in the boot/init call you do

thheller12:04:13

just {:path "/wherever"} in the map you already pass in

pmooser12:04:18

Ah perfect, let me see if I can do it that way instead of by adding another route on the server ...

thheller12:04:40

you can put it wherever you want

thheller12:04:05

the default is just /bootstrap just config :path "/js/bootstrap" if thats the dir you are putting the files in currently

pmooser12:04:51

@thheller Thank you so much. I don't know how many hours that would have taken me to figure out.

pmooser12:04:55

That works perfectly.

metehan13:04:21

hi, when I run shadow-cljs in a particular project it gives "java heap memory.." error on windows. how can i increase the memory limit

thheller14:04:44

@m373h4n "java heap memory.." ?

metehan14:04:05

like this

Exception in thread "async-thread-macro-1" java.lang.OutOfMemoryError: Java heap space
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetPublicMethods(Unknown Source)
        at java.lang.Class.privateGetPublicMethods(Unknown Source)
        at java.lang.Class.getMethods(Unknown Source)
        at clojure.lang.Reflector.getMethods(Reflector.java:498)
        at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:436)
        at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invokeStatic(fs_watch_jvm.clj:17)
        at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invoke(fs_watch_jvm.clj:16)
        at clojure.core$map$fn__5866.invoke(core.clj:2753)
        at clojure.lang.LazySeq.sval(LazySeq.java:42)
        at clojure.lang.LazySeq.seq(LazySeq.java:51)
        at clojure.lang.RT.seq(RT.java:535)
        at clojure.core$seq__5402.invokeStatic(core.clj:137)
        at clojure.core$apply.invokeStatic(core.clj:660)
        at clojure.core$mapcat.invokeStatic(core.clj:2783)
        at clojure.core$mapcat.doInvoke(core.clj:2783)
        at clojure.lang.RestFn.invoke(RestFn.java:423)
        at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invokeStatic(fs_watch_jvm.clj:46)
        at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invoke(fs_watch_jvm.clj:33)
        at shadow.cljs.devtools.server.fs_watch_jvm$start$fn__7286.invoke(fs_watch_jvm.clj:77)
        at clojure.core.async$thread_call$fn__3186.invoke(async.clj:484)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

thheller14:04:25

thats very odd. never seen that before.

thheller14:04:33

do you have like a billion files on the classpath?

metehan15:04:13

i checked there are 39.604 files and 5528 folders ( i don't know what is classpath)

ullrich15:04:24

Does (js/require …) work with shadow to require local .js files or can I only require them in the namespace?

thheller16:04:46

depends on the target you are using?

thheller16:04:19

browser builds only support require in ns. node you can just use js/require

ullrich16:04:34

How about react-native? 🙂

thheller16:04:13

that should be fine, already works for images

thheller16:04:36

@m373h4n how much ram does you machine have? you can tune the memory settings via :jvm-opts ["-Xmx2G"] (for max 2GB ram) in top level shadow-cljs.edn. need to configure via project.clj/deps.edn if you use those.

thheller16:04:02

but it is odd that its running out of memory in places that aren't very memory intense

thheller16:04:22

just make sure you don't have node_modules or so in your classpath

metehan16:04:33

i have 16gb ram

thheller16:04:00

then it should be allowed to use 4GB with default memory rules

thheller16:04:03

that is more than enough

thheller16:04:29

are you just generally out of ram maybe? too much other stuff using everything up?

metehan16:04:38

so :jvm-opts ["-Xmx2G"] for 2gb right

thheller16:04:50

you probably want to tune the memory DOWN then

thheller16:04:57

so try -Xmx1G

metehan16:04:41

it worked 🙂

AJ Snow23:04:47

is there a quick command for reloading the s-cljs server after making changes to the shadow-cljs.edn file or do I just need to restart it?