Fork me on GitHub
#shadow-cljs
<
2020-11-05
>
b407:11:06

is there anybody know how to find a clue of this error?

b407:11:07

1. npx create-cljs-project test-project 2. yarn add react react-dom 3. add reagent 1.0.0 into shadow-cljs.edn 4. shadow-cljs server error: [:failed-to-compare "16.13.0" "16.13.0" #error { :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null" :via [{:type java.lang.NullPointerException   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}] :trace [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14944 invoke "npm_deps.clj" 46]  [clojure.lang.Delay deref "Delay.java" 42]  [clojure.core$deref invokeStatic "core.clj" 2320]  [clojure.core$deref invoke "core.clj" 2306]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14946 invoke "npm_deps.clj" 52]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]  [shadow.cljs.devtools.server.npm_deps$main$fn__15031 invoke "npm_deps.clj" 223]  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]  [clojure.lang.LazySeq sval "LazySeq.java" 42]  [clojure.lang.LazySeq seq "LazySeq.java" 51]  [clojure.lang.RT seq "RT.java" 535]  [clojure.core$seq__5402 invokeStatic "core.clj" 137]  [clojure.core$seq__5402 invoke "core.clj" 137]  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.core$apply invokeStatic "core.clj" 669]  [clojure.core$apply invoke "core.clj" 660]  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.core$apply invokeStatic "core.clj" 665]  [clojure.main$main_opt invokeStatic "main.clj" 514]  [clojure.main$main_opt invoke "main.clj" 510]  [clojure.main$main invokeStatic "main.clj" 664]  [clojure.main$main doInvoke "main.clj" 616]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.main main "main.java" 40]]}] [:failed-to-compare "16.13.0" "16.13.0" #error { :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null" :via [{:type java.lang.NullPointerException   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}] :trace [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14944 invoke "npm_deps.clj" 46]  [clojure.lang.Delay deref "Delay.java" 42]  [clojure.core$deref invokeStatic "core.clj" 2320]  [clojure.core$deref invoke "core.clj" 2306]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14946 invoke "npm_deps.clj" 52]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]  [shadow.cljs.devtools.server.npm_deps$main$fn__15031 invoke "npm_deps.clj" 223]  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]  [clojure.lang.LazySeq sval "LazySeq.java" 42]  [clojure.lang.LazySeq seq "LazySeq.java" 51]  [clojure.lang.RT seq "RT.java" 535]  [clojure.core$seq__5402 invokeStatic "core.clj" 137]  [clojure.core$seq__5402 invoke "core.clj" 137]  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.core$apply invokeStatic "core.clj" 669]  [clojure.core$apply invoke "core.clj" 660]  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.core$apply invokeStatic "core.clj" 665]  [clojure.main$main_opt invokeStatic "main.clj" 514]  [clojure.main$main_opt invoke "main.clj" 510]  [clojure.main$main invokeStatic "main.clj" 664]  [clojure.main$main doInvoke "main.clj" 616]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.main main "main.java" 40]]}]

b407:11:49

and i used shadow-cljs and i install & remove so many program even kernel .. after that it is not working anymore. im trying to find a reason. but dont have a clue.

thheller09:11:32

@b4 which java -version do you use? and which shadow-cljs version?

b409:11:33

java version is openjdk 15.0.1 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

b409:11:24

shadow-cljs 2.11.7

thheller09:11:53

do you use project.clj or deps.edn? or just shadow-cljs.edn?

b409:11:03

only deps.edn

thheller09:11:32

and you have that shadow-cljs version in deps.edn?

b409:11:03

i found adding cljs-ajax into shadow-cljs.edn's dependencies is working but reagent and re-frame is not.

thheller09:11:27

no means you don't use deps.edn right?

b409:11:42

ok. i have test two project. 1st is with deps.edn 2nd is make a project "npx create-cljs-project test-project" that is don't use deps.edn.

b409:11:07

both has same error.

thheller09:11:13

I'm asking because jdk15 removed nashorn. so if you are not actually on the version you listed above that would cause the error.

thheller09:11:30

ie. if you are on an older version. which version is listed when you start shadow-cljs?

b409:11:39

i can't find anything when i exec shadow-cljs server. could u tell me how can i check?

thheller09:11:03

it is listed when you start it

thheller09:11:28

shadow-cljs server then it will print shadow-cljs - server version: <version> running at on startup

b409:11:02

shadow-cljs - HTTP server available at http://localhost:9999 shadow-cljs - server version: 2.9.10 running at http://localhost:9630 shadow-cljs - nREPL server started on port 9100

thheller09:11:25

see that is an old version

thheller09:11:01

do you maybe have an older shadow-cljs global install?

thheller09:11:10

try npx shadow-cljs server or npm install -g shadow-cljs

b409:11:10

it is working.!!! thanks very much.

b409:11:14

and thanks for ur shadow-cljs!

parrot 1
austinbirch13:11:50

Does anybody know if there is a way to evaluate forms from the REPL in the context of a web-worker module? I have my main application loading my web-worker module (setup with :web-worker true in shadow-cljs), but the web-worker keeps some state in an atom that I don’t think I can access from the REPL currently?

victorb13:11:23

Just guessing now but my hunch is on "no", as web workers don't have access to any communication protocols/transports except "postMessage" from the web context. You would have to setup your own "proxiying" somehow (repl =&gt; web context =&gt; postMessage to worker, then back), but not sure how that'd work scratch that, was thinking of service workers, not web workers

victorb13:11:31

Alternatively, write your web-worker in a way that you can either run it embedded in the page or as a proper web worker, so in development you run it in the same scope as the web app itself, and you can use the repl normally. When you wanna release/deploy, make the embedded web worker into a proper one where you use postMessage to communicate

thheller13:11:07

web workers can open websockets just fine which is the only things the shadow-cljs REPL needs

austinbirch14:11:59

@UEJ5FMR6K yeah, that’s the other alternative. I have avoided that so far just because the postMessage boundary between the worker and the main thread keeps me honest (ha!), and gives a good indication of the general performance characteristics for the release build. I do something similar though when working on the worker from the REPL - I sometimes just load the namespace into the main thread, work on it in pieces in a REPL-driven way, then once I’m done saving the file updates the code in the worker context.

thheller13:11:08

@austinbirch you can REPL in the webworker just fine but no editor currently allows you selecting the runtime to eval in

thheller13:11:46

one way you can is using the UI. just tap> something in the worker and it will show up in the web UI inspect

thheller13:11:53

that has an eval window

austinbirch13:11:06

Ah, right - that makes sense.

austinbirch13:11:36

The actual problem I was having was that I’ve fallen into a more REPL-driven workflow, and that stopped working for the web worker. Not really a big deal though - I can just lean on the hot reloading and tap> / js/console.log or whatever. Thanks for the help.

thheller13:11:11

you can do the REPL workflow in web workers just fine

thheller13:11:44

BUT when you open a website with code using a worker you'll have two completely separate runtimes

austinbirch13:11:48

Not redefining functions etc from Cursive though? Ends up defining the functions in the ‘main thread’ rather than the web worker context?

thheller13:11:57

one is the regular webpage and one is the worker. they don't share anything

austinbirch13:11:58

Yeah, that’s it.

thheller13:11:09

so when you eval stuff you need to "select" which runtime you actually want to work in

thheller13:11:27

and that is unfortunately not supported by any editor at the moment so it is kind of clunky to do

austinbirch13:11:51

That’s fine, I’d rather keep the REPL working for the regular webpage and just use reloading + tap> for the worker context. It’s not that bad of a tradeoff, still a nice workflow.

austinbirch13:11:02

If editors added support for selecting the runtime then I’d probably use that, but it’s not a huge problem.

sb13:11:28

What is the best practice to use circleci with shadow-cljs? is there any example of config (shadow-cljs project > config.yml)? Thanks!

thheller14:11:06

to do what exactly? you can just run the normal commands

sb14:11:52

I would like to learn from others how they create the .yml file etc (avoid fails, faster learning curve etc). Nothing extra

thheller14:11:22

I also have it setup for shadow-cljs itself

thheller14:11:49

although that first uses lein to do stuff since I can't use shadow-cljs only after I have built it so it should be an unconventional setup

victorb14:11:52

@sb example config for a project I'm working on: https://github.com/instantwebsite/dashboard/blob/master/.circleci/config.yml (fairly trivial stuff though)

sb14:11:50

thank you very much ! that is really cool example!!

👍 1
victorb14:11:11

if you want the compiled output, just add another npx shadow-cljs compile step + archive_artifacts

👍 1
austinbirch14:11:23

> Just `tap>` something in the worker and it will show up in the web UI inspect > that has an eval window @thheller I’ve just used the Inspect UI for the first time… wow! This is so great! Thanks so much for your work on this, it’s really really helpful. Today has been a good developer tooling day for me; I’ve been trying out https://github.com/jpmonettas/flow-storm-debugger and it’s pretty smart, and now I’ve got Inspect to use as well.

👍 1
benny16:11:36

after shadow’s dev server reloads my app, the dom appears to be reset to this:

<html><head></head><body><input type="text" name="history_state1" id="history_state1" style="display:none"></body></html>
why isn’t it at a very minimum using the static html page i have for the react container?

thheller17:11:14

this is not shadow-cljs doing that

thheller17:11:26

something in your code (or libraries) is responsible for that

thheller17:11:18

looks like you might be initializing goog.History multiple times. that does that IIRC.

benny18:11:00

thank you so much! that was it