Fork me on GitHub
#shadow-cljs
<
2019-09-04
>
flowthing09:09:47

After updating to 2.8.52, when I run shadow-cljs watch app, I get an error like this: RejectedExecutionException: Task [email protected] rejected from [email protected][Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 306] Deleting the .shadow-cljs directory makes it go away, but it reappears when I restart shadow-cljs with an existing .shadow-cljs directory. Anyone come across the same issue?

flowthing09:09:29

I'm trying to upgrade from 2.8.39, which works fine.

flowthing09:09:54

Stacktrace:

RejectedExecutionException: Task [email protected] rejected from [email protected][Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 306]
	java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution (ThreadPoolExecutor.java:2063)
	java.util.concurrent.ThreadPoolExecutor.reject (ThreadPoolExecutor.java:830)
	java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1379)
	java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:112)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.async/queue-task (async.clj:11)
	shadow.build.async/queue-task (async.clj:4)
	shadow.build.output/flush-sources (output.clj:245)
	shadow.build.output/flush-sources (output.clj:240)
	shadow.build.output/flush-sources (output.clj:242)
	shadow.build.output/flush-sources (output.clj:240)
	shadow.build.targets.browser/flush-unoptimized! (browser.clj:654)
	shadow.build.targets.browser/flush-unoptimized! (browser.clj:642)
	shadow.build.targets.browser/flush-unoptimized (browser.clj:668)
	shadow.build.targets.browser/flush-unoptimized (browser.clj:665)
	shadow.build.targets.browser/flush (browser.clj:679)
	shadow.build.targets.browser/flush (browser.clj:671)
	shadow.build.targets.browser/process (browser.clj:823)
	shadow.build.targets.browser/process (browser.clj:801)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--14088 (build.clj:143)
	shadow.build/process-stage (build.clj:140)
	shadow.build/process-stage (build.clj:132)
	shadow.build/flush (build.clj:423)
	shadow.build/flush (build.clj:418)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:315)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:300)
	shadow.cljs.devtools.server.worker.impl/eval15252/fn--15254 (impl.clj:695)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--14897/fn--14898/fn--14906 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--14897/fn--14898 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--14897 (util.clj:257)
	java.lang.Thread.run (Thread.java:748)

thheller09:09:38

how do you run shadow-cljs? using lein/deps.edn? embedded?

flowthing09:09:46

Lein sorry, misread: I run it via npm, but I'm using Leiningen also.

flowthing09:09:13

Actually, just a moment...

thheller09:09:52

others have reported running into this occasionally but I have never been able to reproduce

thheller09:09:18

and I have no clue how this could happen other than trying to actually interrupt a build

flowthing09:09:18

Right. It is certainly weird. I can certainly try to look into it, but I'm not sure where I'd even start.

thheller09:09:49

make sure you only have one shadow-cljs instance running for the project

flowthing09:09:57

OK, will double-check.

thheller09:09:01

do you connect a REPL before this happens? or does it happen on its own by just running shadow-cljs watch app?

flowthing09:09:20

Happens on its own.

flowthing09:09:53

Here's a fuller terminal output:

shadow-cljs - config: /Users/eerohe/Code/ci/shadow-cljs.edn  cli version: 2.8.52  node: v11.15.0
shadow-cljs - running: lein with-profile +cljs run -m shadow.cljs.devtools.cli --npm watch app
Warning: implicit hook found: lein-environ.plugin/hooks
Hooks are deprecated and will be removed in a future version.
NPM dependency "highlight.js" has installed version "^9.15.10"
"9.15.8" was required by jar:file:/Users/eerohe/.m2/repository/day8/re-frame/re-frame-10x/0.4.2/re-frame-10x-0.4.2.jar!/deps.cljs
shadow-cljs - server version: 2.8.52 running at 
shadow-cljs - nREPL server started on port 50001
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
shutting down ...
shutting down ...
[:app] Build failure:
RejectedExecutionException: Task [email protected] rejected from [email protected][Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 306]
  java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution (ThreadPoolExecutor.java:2063)
  java.util.concurrent.ThreadPoolExecutor.reject (ThreadPoolExecutor.java:830)
  java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1379)
  java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:112)
  sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
  sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
  sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke (Method.java:498)
  clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
  clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
  shadow.build.async/queue-task (async.clj:11)
  shadow.build.async/queue-task (async.clj:4)
  shadow.build.output/flush-sources (output.clj:245)
  shadow.build.output/flush-sources (output.clj:240)
  shadow.build.output/flush-sources (output.clj:242)
  shadow.build.output/flush-sources (output.clj:240)
  shadow.build.targets.browser/flush-unoptimized! (browser.clj:654)
  shadow.build.targets.browser/flush-unoptimized! (browser.clj:642)
  shadow.build.targets.browser/flush-unoptimized (browser.clj:668)
  shadow.build.targets.browser/flush-unoptimized (browser.clj:665)
  shadow.build.targets.browser/flush (browser.clj:679)
  shadow.build.targets.browser/flush (browser.clj:671)
  shadow.build.targets.browser/process (browser.clj:823)
  shadow.build.targets.browser/process (browser.clj:801)
  clojure.lang.Var.invoke (Var.java:384)
  shadow.build/process-stage/fn--14088 (build.clj:143)
  shadow.build/process-stage (build.clj:140)
  shadow.build/process-stage (build.clj:132)
  shadow.build/flush (build.clj:423)
  shadow.build/flush (build.clj:418)
  shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:315)
  shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:300)
  shadow.cljs.devtools.server.worker.impl/eval15252/fn--15254 (impl.clj:695)
  clojure.lang.MultiFn.invoke (MultiFn.java:234)
  shadow.cljs.devtools.server.util/server-thread/fn--14897/fn--14898/fn--14906 (util.clj:285)
  shadow.cljs.devtools.server.util/server-thread/fn--14897/fn--14898 (util.clj:284)
  shadow.cljs.devtools.server.util/server-thread/fn--14897 (util.clj:257)
  java.lang.Thread.run (Thread.java:748)

Worker shutdown.

thheller09:09:06

shutting down ...

thheller09:09:15

so the server is actually shutting down

thheller09:09:23

others have reported this happening due to memory issues

thheller09:09:45

try setting :jvm-opts ["-Xmx2G"] in project.clj

thheller09:09:59

to limit to maximum 2gig ram

thheller09:09:25

1G is typically enough

thheller09:09:55

dunno why it works with older versions though. I didn't change anything that would affect memory issues

flowthing09:09:27

By the way, I also get this if I remove the :lein key from my shadow-cljs.edn:

[2019-09-04 12:34:47.608 - WARNING] :shadow.cljs.devtools.server.fs-watch-hawk/hawk-start-ex
ArityException Wrong number of args (0) passed to: clojure.core/juxt
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	hawk.core/watch! (core.clj:79)
	hawk.core/watch! (core.clj:59)
	shadow.cljs.devtools.server.fs-watch-hawk/start* (fs_watch_hawk.clj:41)
	shadow.cljs.devtools.server.fs-watch-hawk/start* (fs_watch_hawk.clj:29)
	shadow.cljs.devtools.server.fs-watch-hawk/start (fs_watch_hawk.clj:102)
	shadow.cljs.devtools.server.fs-watch-hawk/start (fs_watch_hawk.clj:100)
	clojure.lang.Var.invoke (Var.java:399)
	shadow.cljs.devtools.server.fs-watch/start (fs_watch.clj:26)
	shadow.cljs.devtools.server.fs-watch/start (fs_watch.clj:11)
	shadow.cljs.devtools.server/start!/fn--16824 (server.clj:435)

thheller09:09:01

hmm what are your :source-paths then?

flowthing09:09:57

In my shadow-cljs.edn? None, so that's probably the issue. Maybe disregard that for now, would probably need to make more extensive changes to my shadow-cljs.edn to eliminate Leiningen. 🙂

flowthing09:09:17

Seems like increasing memory might've done the trick...

thheller09:09:23

yes if you remove lein you need to transfer :source-paths and :dependencies

thheller09:09:36

you actually decreased memory

thheller09:09:41

the JVM defaults to using a higher limit

flowthing09:09:47

Hm, doesn't Xmx specify the maximum memory allocation pool?

thheller09:09:59

maximum heap size yes

flowthing09:09:44

I always thought that was platform-specific in some way. :thinking_face:

thheller09:09:27

the default is 8gb on my machine (32gb ram)

thheller09:09:16

java -XX:+PrintFlagsFinal -version | grep HeapSize

thheller09:09:24

shows your platform default

thheller09:09:44

size_t MaxHeapSize = 8573157376 {product} {ergonomic}

flowthing09:09:08

Right, seems to be 4GB for me.

flowthing09:09:38

Learned something new in addition to finding a fix for my issue. Huge thanks once again for your help!

thheller09:09:39

yeah so something in the OS seems to be killing the shadow-cljs process

thheller09:09:47

are in on OSX by any chance?

thheller09:09:25

so far I think everyone reporting this was on OSX

thheller09:09:46

good to know for the future 😛

flowthing09:09:31

Just as a sanity check, I tried copying my :dependenciesand {:dev {:dependencies ,,, }} from project.clj into shadow-cljs.edn wholesale and specifying :source-paths and the issue doesn't occur.

thheller09:09:37

do you maybe have additional lein plugins or ~/.lein/profiles.clj or so adding extra deps?

flowthing09:09:02

Good point, I could try disabling those.

thheller09:09:09

but yeah running through lein consumes slightly more memory since it starts 2 JVMs

flowthing09:09:01

Replacing my ~/.lein/profiles.clj (which loads some plugins) with an empty map also solves the issue.

thheller09:09:14

good to know

flowthing10:09:09

https://gist.github.com/eerohele/87a37812729f87d8b27cd9d3ca94e5e3 Made this in case someone else tries googling the same issue.

👍 4
thheller10:09:17

the exception is just a symptom of the shutting down .... so thats the real problem

flowthing10:09:01

Right, thanks; updated the Gist to reflect that.

kaaninho13:09:42

Hey! I am using shadow-cljs and want to get integration with Emacs. Putting [cider/cider-nrepl "0.18.0"] in the shadow-cljs.edn file (under :dependencies) works fine. But when I remove it there and instead paste it into user config file ~/.shadow-cljs/config.edn it breaks. Some ideas?

thheller13:09:31

~/shadow-cljs/config.cljs should be ~/shadow-cljs/config.edn?

thheller13:09:52

can you paste the actual content?

thheller13:09:18

oh and which version are you on? cider-nrepl 0.18 is kinda old

kaaninho13:09:39

{:dependencies
 [[cider/cider-nrepl "0.18.0"]]

 :deps-aliases [:cider]}

thheller13:09:12

should work fine?

kaaninho13:09:31

In Emacs, it finds the correct Port, but after choosing that, I get error in process filter: Wrong type argument: stringp, nil

kaaninho13:09:24

(After saying [nREPL] Direct connection to localhost:60273 established)

dpsutton13:09:38

what does m-x cider-version report?

kaaninho13:09:25

CIDER 0.22.0snapshot (package: 20190817.800)

dpsutton13:09:02

instead of 0.18.0 use 0.22.2 for your cider-nrepl version

thheller13:09:40

I have no clue about the emacs side of things. you can run shadow-cljs clj-repl and then ( "cider/nrepl.clj") to verify it is actually on the classpath

thheller13:09:23

or just (System/getProperty "java.class.path") and look for the cider entry

kaaninho13:09:10

The first one gets me a nil - that shouldn't be, should it?

thheller13:09:40

hmm that should not be nil

thheller13:09:55

well actually no clue since I don't know if thats the correct filename

thheller13:09:17

but should be correct

dpsutton13:09:41

the client is 0.22 and cider-nrepl is 0.18. No clue what it should be. Bump the dep to [cider/cider-nrepl "0.22.2"]

kaaninho13:09:02

I did, doesn't work

thheller13:09:05

which shadow-cljs version?

dpsutton13:09:07

same error?

kaaninho13:09:53

shadow-cljs - server version: 2.7.9

thheller13:09:33

update that. can't remember which version I added support for ~/.shadow-cljs/config.edn. it may be too old for that

thheller13:09:54

2.8.52 is current

kaaninho13:09:26

Ah, I'll try that! Reporting back... .

mccraigmccraig13:09:03

i'm getting compile errors from an ns :require form which works in shadow-cljs node-repl with (require <...>). the form is:

["google-libphonenumber"
             :refer [PhoneNumber]
             :rename {PhoneNumber.CountryCodeSource ccs
                      PhoneNumberFormat pnf
                      PhoneNumberUtil pnu}]
am i doing something obviously wrong ?

kaaninho13:09:26

Now it's connecting and asking about the build (`:app`). After that I don't get a cljs-repl tho and can't eval buffers. In the clj-repl is the warning

WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0-SNAPSHOT (package: 20190618.716) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.[:app] Build completed. (1647 files, 1618 compiled, 0 warnings, 49,33s)
pasted.

thheller13:09:49

@mccraigmccraig this isn't allowed PhoneNumber.CountryCodeSource ccs and should never work

thheller13:09:22

purely accidental when it does

thheller13:09:12

but what is the compile error?

mccraigmccraig13:09:38

------ WARNING #3 -  -----------------------------------------------------------
 Resource: er_model/util/phone_number.cljc:3:7
 variable pnu is undeclared
--------------------------------------------------------------------------------
------ WARNING #4 -  -----------------------------------------------------------
 Resource: er_model/util/phone_number.cljc:8:200
 variable ccs is undeclared
--------------------------------------------------------------------------------
------ WARNING #5 -  -----------------------------------------------------------
 Resource: er_model/util/phone_number.cljc:186:83
 variable pnf is undeclared
--------------------------------------------------------------------------------

mccraigmccraig13:09:01

so it's complaining about the aliases in the ns form

thheller13:09:04

and the ns form was?

mccraigmccraig13:09:25

(ns er-model.util.phone-number
  (:require
   [plumbing.core :refer [assoc-when defnk]]
   #?(:cljs ["google-libphonenumber"
             :refer [PhoneNumber]
             :rename {CountryCodeSource ccs
                      PhoneNumberFormat pnf
                      PhoneNumberUtil pnu}]))
  #?(:clj
     (:import
      [com.google.i18n.phonenumbers
       PhoneNumberUtil
       PhoneNumberUtil$PhoneNumberFormat
       Phonenumber$PhoneNumber
       Phonenumber$PhoneNumber$CountryCodeSource])))

thheller13:09:34

that is incorrect

thheller13:09:48

hmm no wait

thheller13:09:20

I hate cljc so much ... this is so unreadable 😛

thheller13:09:33

it compiles fine for me?

thheller13:09:58

although I tested in a cljs file

mccraigmccraig13:09:21

hmm. i got rid of the wrong :rename, but i'm still getting errors relating to the other :rename symbols

mccraigmccraig13:09:00

i'll try just getting rid of all the :renames and see how that goes

thheller13:09:29

(ns demo.cljc
  (:require
    #?(:cljs ["google-libphonenumber"
              :refer [PhoneNumber]
              :rename {CountryCodeSource ccs
                       PhoneNumberFormat pnf
                       PhoneNumberUtil pnu}])))

(js/console.log ccs pnf pnu)

thheller13:09:39

this compiles and runs fine for me although ccs is undefined

mccraigmccraig13:09:13

yeah, it works fine for me in the node-repl... and ccs is an attribute of PhoneNumber which is where i was going with the accidentally working PhoneNumber.CountryCodeSource thing

mccraigmccraig13:09:26

just doesn't compile from the .cljc

thheller13:09:39

works fine for me

thheller13:09:53

which version? using lein/deps?

kaaninho13:09:48

Gotta go, ty for helping me, @thheller and @dpsutton

mccraigmccraig13:09:02

cli version: 2.8.39 node: v12.5.0 and not using lein or deps directly

mccraigmccraig14:09:33

odd. the PhoneNumberFormat and PhoneNumberUtil objects don't seem to be there when compiling, although they do when running the repl

mccraigmccraig14:09:46

but the PhoneNumber object is there in both cases

mccraigmccraig19:09:53

finally got it to work @thheller , and ditched the .cljc in favour of two small equivalent .cljs and .clj files - much easier to read

thheller19:09:55

still would like to find out what was causing the issue for you though 😛

mccraigmccraig19:09:11

i'm not sure why, but in the google-libphonenumber lib the PhoneNumberUtil and PhoneNumberFormat don't work in the :require but are accessible as properties of the default export - https://gist.github.com/mccraigmccraig/1e8dafda6d86ea6ae0018b492992ee40

thheller19:09:22

it compiled absolutely fine for me in .cljc and .cljs

thheller19:09:56

you are using it incorrectly

thheller20:09:41

:as sets up a namespace alias. so you should NOT be using (.-PhoneNumberUtil phone-number) and use the correct phone-number/PhoneNumberUtil instead

mccraigmccraig20:09:43

ok, cool - i initially tried to :refer [PhoneNumber PhoneNumberUtil PhoneNumberFormat] but that lead to nils for PhoneNumberUtil and PhoneNumberFormat

thheller20:09:25

phone-number/PhoneNumberUtil would be nil then as well?

thheller20:09:40

something weird is going on in your setup if it is?

mccraigmccraig20:09:41

let me try again, now i've got it all simplified

thheller20:09:06

:refer and :rename work absolutely fine for me

mccraigmccraig20:09:06

i'm using :refer in lots of other namespaces without issue...

mccraigmccraig20:09:34

never used :rename before, but i was trying to duplicate what a cljsjs lib was doing

mccraigmccraig20:09:20

ok, well now the :refer works fine, so i have no idea what was causing my issue before

mccraigmccraig20:09:10

i'm sorry if i wasted your time

thheller20:09:31

:rename should work fine except for the Thing.X so a dot is technically questionable

thheller20:09:52

it kinda works but it isn't really recommended to do that

eag22:09:53

I'm trying to use highcharts to create a reagent component. I think I'm having trouble with an Extern, I can't get it to work. The example I followed uses cljsjs and obviously works here. https://ingesolvoll.github.io/posts/2018-12-04-revisited-how-to-use-a-charting-library-in-re-frame/ I added :compiler-options {:infer-externs :auto} to my shadow-cljs.edn But the mount-chart function blows up with an undefined argument. Highcharts How can I make that symbol stick ?

(ns prod-inv-ui.views
  (:require
   [reagent :as r]
   ...
   ["highcharts" :as hc]))

(defn mount-chart [comp]
  (hc/chart Highcharts (r/dom-node comp) (clj->js (r/props comp))))

;; with cljsjs
;; (defn mount-chart [comp]
;;   (.chart js/Highcharts (r/dom-node comp) (clj->js (r/props comp))))

(defn update-chart [comp]
  (mount-chart comp))

(defn chart-inner []
  (r/create-class
   {:component-did-mount   mount-chart
    :component-did-update  update-chart
    :reagent-render        (fn [comp] [:div])}))

(defn chart-outer [config]
  [chart-inner @config])