Fork me on GitHub
#shadow-cljs
<
2019-09-05
>
thheller07:09:21

@eag it would help to know what you actual error is? I don't see anything that would require externs?

thheller07:09:24

I see an error but that would blow up in development also?

(defn mount-chart [comp]
  (hc/chart Highcharts (r/dom-node comp) (clj->js (r/props comp))))
there is an extra Highcharts that seems undefined? and should just be
(defn mount-chart [comp]
  (hc/chart (r/dom-node comp) (clj->js (r/props comp))))

eag07:09:53

If I do that, take out the Highcharts, I get this.

highcharts.js:271 Uncaught TypeError: Cannot read property 'series' of null
    at c$jscomp$1.Chart.init (highcharts.js:271)
    at c$jscomp$1.Chart.getArgs (highcharts.js:271)
    at new c$jscomp$1.Chart (highcharts.js:270)
    at Object.c$jscomp$1.chart (highcharts.js:270)
    at Constructor.prod_inv_ui$views$mount_chart (views.cljs:14)
    at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount (component.cljs:194)
    at Constructor.componentDidMount (factory.js:666)
    at commitAllLifeCycles (react-dom.development.js:17335)
    at HTMLUnknownElement.callCallback (react-dom.development.js:150)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)

eag07:09:23

with hc/Highcharts I get an undefined symbol...

thheller07:09:32

series is likely expected to be a prop? did you check what you are passing to it? try logging (js/console.log (clj->js (r/props comp))) in the mount-chart fn?

thheller07:09:20

also check if you are using the correct version? you just might have a different highcharts version from the one defined in cljsjs?

eag07:09:30

Ok. It's working. Thank you for the prompts. My config variable was not dereferenced. And i don't really need the externs... Sorry about that, I got mislead by all the examples I've been reading.

aisamu13:09:52

Hi! We've observed compilation failures when using the explicit (. var -field) form inside some forms (`if`, when, but not do)

;; Both work
(.-ok response)
(. response -ok)

;; Works
(if (.-ok response)
  true
  false)

;; Fails
(if (. response -ok)
  true
  false))

  19 |  (if (. response -ok)
--------^-----------------------------------------------------------------------
Error in phase :compilation
IllegalArgumentException: no conversion to symbol
	clojure.core/symbol (core.clj:596)
	clojure.core/symbol (core.clj:589)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:849)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:837)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:840)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:837)
	shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:357)
	shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:142)
	cljs.analyzer/resolve-existing-var (analyzer.cljc:1269)
	cljs.analyzer/resolve-existing-var (analyzer.cljc:1264)
Latest (`2.8.52`) also contains the issue, unfortunately. We've quickly tested it without shadow and it doesn't seem to break there 😞

thheller13:09:53

@aisamu what is response? does it also not work when changing the name?

thheller13:09:12

and what is the rest of the stacktrace? is this inside some other macro maybe trying to rewrite it? (eg. core.async)

thheller13:09:50

hmm I found it ... trying to figure out why it happens ... looks to me like a bug in CLJS

aisamu19:09:24

Thank you! I'm assuming you've already figured most of it out, but response is a #js object. Using a regular CLJS map or changing the names give us the same error. Surprisingly, running it on app.klipse.tech doesn't seem to break things!

thheller19:09:19

klipse uses the self-hosted compiler

thheller19:09:46

the bug is getting fixed in CLJS properly https://clojure.atlassian.net/browse/CLJS-3163

thheller19:09:01

hesitant to add a temporary workaround

👍 4
aisamu19:09:16

Not a problem - the alternative version (.-ok works as expected!

kenny15:09:47

I get these sorts of errors after restarting shadow-cljs a few times:

{:type java.io.FileNotFoundException
   :message "/home/kenny/compute_software_mono/projects/ui/src/compute/ui/login/views.cljs (Too many open files)"
   :at [java.io.FileInputStream open0 "FileInputStream.java" -2]}
Typically the only way to fix it is restarting my computer. Anyone know of a better solution?

thheller15:09:44

hmm odd. are the old processes maybe hanging around for some reason?

thheller15:09:56

otherwise all the files they had open should be closed?

kenny15:09:11

Maybe. I tried killall node but no node processes are found.

thheller15:09:32

check java. the node process only starts the real java process

thheller15:09:56

which OS is that? looks like linux? maybe you are running into some kind of system limits for other reasons?

kenny15:09:47

Oh. Will try killing all java. Was using a a hand-rolled lib to run multiple processes at once that could've left processes running. Switching to npm-run-all in hope that it is better at killing processes. I'm on Ubuntu. I've set that file limit pretty high.

kenny15:09:18

Still got the exception after killall java 😞

thheller15:09:40

maybe try debugging with lsof or so to see who has all those open files

kenny15:09:01

The output of that command is so massive. Any idea what to look for?

thheller15:09:31

been a while since I've done that. can't really remember all the details

kenny15:09:10

It's a 50+ mb file so pretty overwhelming 😵

thheller15:09:39

lsof | grep .cljs maybe

thheller15:09:57

see if there are other processes with those files still open

kenny15:09:58

It only ever happens with shadow-cljs. There's gotta be a shadow process still running somewhere.

thheller15:09:41

well depending on the size of your build it has to open a lot of files 😛

kenny15:09:30

Yeah... There can't be more than 60 namespaces. Guessing it's the node_modules that is the issue.

thheller15:09:53

yeah thats easily thousands of files 😛

kenny15:09:00

IntelliJ was the only thing holding onto .cljs things and that was just a few maven deps. e.g. /home/kenny/.m2/repository/rewrite-cljs/rewrite-cljs/0.4.4/rewrite-cljs-0.4.4.jar

kenny15:09:32

I start shadow-cljs with npx. Perhaps that is hiding the actual process somehow?

thheller15:09:03

not really hiding. it starts a node process, that starts the actual java process

kenny15:09:36

I would've expected killall java to have worked then

thheller15:09:52

well are there any left? 😛

thheller15:09:08

it should certainly kill shadow-cljs yes

kenny15:09:16

killall java
java: no process found

kenny15:09:33

Still a mystery. Just going to restart so I can get work done again 🙂

thheller15:09:36

dunno. something must have all those files open 😛

thheller15:09:52

don't restart

thheller15:09:02

otherwise the issue is gone again and no chance to debug further

thheller15:09:35

ps aux | sed 1d | awk '{print "fd_count=$(lsof -p " $2 " | wc -l) && echo " $2 " $fd_count"}' | xargs -I {} bash -c {}

thheller16:09:31

find -maxdepth 1 -type d -name '[0-9]*' \
     -exec bash -c "ls {}/fd/ | wc -l | tr '\n' ' '" \; \
     -printf "fds (PID = %P), command: " \
     -exec bash -c "tr '\0' ' ' < {}/cmdline" \; \
     -exec echo \; | sort -rn | head
seems nicer 😛

kenny16:09:12

Too late 😬 I'm sure I can reproduce it if needed. I usually only start shadow-cljs once per day. Today I restarted it a few times because I was updating deps.

thheller16:09:34

yeah check the next time when you run into it

kenny16:09:33

I did see that SO post and tried a few of the commands in it. I don't think they gave me anything obviously wrong. Though, on one of them, it wasn't clear what the columns it was outputting meant.

kenny16:09:49

Oh, now this is interesting. First time running after a restart and I got it. The only thing I've changes is my deps.

kenny16:09:17

That find command returns nothing.

kenny16:09:14

The ps is the one that outputs two columns. Any idea what the columns mean? First one is, maybe, pid and second is open files?

thheller16:09:48

yes exactly

nate16:09:05

Hello, does dynamic module loading work with multimethods ?

thheller16:09:46

@nisehl depends on what you mean by that?

thheller16:09:07

loading modules dynamically will add their defmethod definitions yes

nate16:09:25

ah that was what I meant, if I have a defmethod defined in a module that I chose to lazy load later, doesn't seem to be registred here, but i'll investigate and let you know, might be something else causing the issue

nate16:09:10

(in the case of defmulti being defined in core and defmethod in a lazy loadable module)

thheller16:09:23

@nisehl remember that the load is async so if you trigger the load and immediately call the defmulti then the code will not have loaded yet

nate16:09:24

I do check if ready? before making calls

thheller16:09:59

and is it ready?

thheller16:09:34

js/console.log is your friend 😉

nate16:09:25

I'm using shadow.lazy/ready? and shadow.lazy/load, is it async for every function ?

nate16:09:31

I'm defining a specific noop fn called init in my separate modules, I call it using lazy/load and once it's lazy/ready?, I consider all parts of the said module as ready, am I doing it wrong ?

thheller16:09:35

ready? is not async. load is

thheller16:09:00

depends. how do you load lazy/load?

nate16:09:46

(lazy/load (lazy/loadable mynamespace.mymodule/init))

thheller16:09:02

that only triggers the load but does not wait for it

thheller16:09:09

(-> (lazy/load (lazy/loadable mynamespace.mymodule/init)) (.then (fn [init-fn] the-defmethod-is-ready-now))

nate16:09:12

yes I didn't past all the code but along the chain, in .then() is all the module to be considered loaded ?

nate16:09:45

thanks !

ShaneLester16:09:51

Anyone have a sort of autoformatter-on-save set up to work with shadow before I hack one together myself?

thheller16:09:02

seems like something your editor should do? 😛

ShaneLester16:09:28

yeah. true. I kinda want to do it this way so that I force other people working on my project to format in the same way. haha.

ShaneLester16:09:54

(we all use diff editors)

kenny16:09:38

Hmm. So I recently switched to PopOS, which is a flavor of Ubuntu. I think this may have reset my ulimit file limit.

ulimit -n
4096
cat /proc/sys/fs/file-max
1000000
Still getting the too many open files exception...

thheller16:09:23

yes but who has those files open?

thheller16:09:47

4096 is easy to reach when using a couple npm packages

kenny16:09:20

I can't figure out a way to get it to go any higher. I've tried 5 different methods and none of them let me set it higher.

kenny16:09:56

I've set the limits in /etc/security/limits.conf to 500000. I've set /etc/sysctl.conf fs.file-max to 1000000.

thheller16:09:04

that goes far beyond my linux knowledge 😛

David Pham16:09:14

Is it prohibited to have lein and shadow-cljs in the same project? Some nice facilities are built only with lein.

thheller16:09:43

no why would it be?

thheller16:09:13

you can run them separately, make shadow-cljs use lein or run shadow-cljs embedded in your lein process

kenny16:09:56

Same... It's mind boggling how difficult this is.

David Pham16:09:11

@thheller thanks a lot for your answer!

kenny16:09:44

This is super weird:

[email protected]:~$ whoami
kenny
[email protected]:~$ ulimit -Hn
4096
[email protected]:~$ su kenny
Password: 
[email protected]:~$ ulimit -Hn
65535

kenny20:09:33

I updated to PopOS 19.04 and it solved the issue. Very strange. Happy to be able to get some real work done now 🙂

knubie22:09:44

Has anyone run into the issue where localhost:8021 (tests) always displays shadow-cljs - Stale Client! You are not using the latest compilation output!?

thheller22:09:30

@steedman87 either your server is caching or you changed the output files but didn't update the html accordingly

knubie12:09:48

@thheller thanks for the response, the issue was that I changed the :test-dir setting, but forgot to update the [:devtools :http-root] setting. :thumbsup: