Fork me on GitHub
#shadow-cljs
<
2018-01-26
>
thheller08:01:18

@mhuebert also 10.13 macOS?

mhuebert17:01:35

Yep - 10.13.2

mhuebert14:01:56

Although I also got these same kinds of errors on CircleCI w/o Mac OS

thheller14:01:03

can you test running the npx shadow-cljs server standalone and if killing it with CTRL+C leaves the orphan java process?

mhuebert10:01:13

no orphan process there

mhuebert10:01:52

right now in one project, i can start a server with just a warning (“TCP Port 9630 in use” - despite no java process still running), while in another project (maria) when I try to start a server, I get this:

mattpro:editor MattPro$ npx shadow-cljs server
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - starting ...
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean?
[2018-01-28 11:32:41 - WARNING] TCP Port 9630 in use.
BindException: Address already in use
	java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
	java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:382)
	java.net.ServerSocket.bind (ServerSocket.java:375)
	java.net.ServerSocket.bind (ServerSocket.java:329)
	clojure.tools.nrepl.server/start-server (server.clj:149)
	clojure.tools.nrepl.server/start-server (server.clj:121)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:278)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:266)

thheller10:01:25

thats the nrepl server failing

thheller10:01:33

if you set a fixed port for nrepl that happens

mhuebert10:01:44

ah i’ll remove that option

thheller10:01:15

yeah fixed ports are a problem when running multiple shadow-cljs instances

mhuebert10:01:42

in this case there was no other instance visibly running

thheller10:01:23

hmm I don't understand. if port 9630 is blocked something must be running

mhuebert10:01:31

but.. when I run this in the maria project I don’t see any main processes so maybe i’m just not seeing them

thheller10:01:56

ps ax | grep java

thheller10:01:59

doesn't list anything?

mhuebert10:01:19

looks like they are called java processes when i run the command from maria

mhuebert10:01:27

and main when i run from my other project

thheller10:01:45

hmm? should always be called java

thheller10:01:50

no idea what main would be?

mhuebert10:01:25

it starts out as java, and then at some point changes to main (or the first process ends and another one called main starts, however that works)

thheller10:01:56

hmm what does ps ax for that process look like?

mhuebert10:01:33

PID   TT  STAT      TIME COMMAND
77080   ??  Ss     1:20.61 /usr/bin/java -Djava.util.logging.config.file=target

thheller10:01:22

where is it called main?

mhuebert10:01:20

in Activity Monitor

thheller10:01:57

when you run npx shadow-cljs server that is called main as well?

mhuebert10:01:04

same — while it’s loading it is called java, around the time it’s finished loading the name changes to main

thheller10:01:42

my mac is still on 10.12 where this doesn't happen

thheller10:01:51

currently switching my main machine over to windows

thheller10:01:09

might attempt the macos upgrade later

mhuebert10:01:56

this still never works:

mattpro:editor MattPro$ npx shadow-cljs start; npx shadow-cljs clj-run '(+ 1 1);'
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - server starting ..................................................... ready!
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?

thheller10:01:07

I don't get it, that always works for me

thheller10:01:02

whats the state of java processes directly after that?

thheller10:01:25

can you rm -rf target/shadow-cljs before running that

thheller10:01:34

and then run the command?

thheller10:01:45

ls -ahl target/shadow-cljs after?

thheller10:01:11

npx shadow-cljs start; npx shadow-cljs clj-eval '(+ 1 1)'
shadow-cljs - config: /mnt/c/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.144
shadow-cljs - updating dependencies
Retrieving thheller/shadow-cljs/2.0.144/shadow-cljs-2.0.144.pom from 
Retrieving thheller/shadow-cljs/2.0.144/shadow-cljs-2.0.144.jar from 
shadow-cljs - dependencies updated
shadow-cljs - server starting ........................................ ready!
shadow-cljs - config: /mnt/c/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.144
shadow-cljs - connected to server
2

mhuebert10:01:29

i have ssh’d into circleci right now, so whatever OS they are running, and same thing:

root@b4b33f696572:~# cd project/editor/
root@b4b33f696572:~/project/editor# npx shadow-cljs stop;
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.140
shadow-cljs - server not running
root@b4b33f696572:~/project/editor# npx shadow-cljs start; npx shadow-cljs clj-eval '(+ 1 1)'
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.140
shadow-cljs - server starting ........................... ready!
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.140
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
deleted pid file, please retry command to start new server
root@b4b33f696572:~/project/editor#

thheller10:01:12

target/shadow-cljs contents?

mhuebert10:01:37

root@b4b33f696572:~/project/editor# cd target/shadow-cljs/
root@b4b33f696572:~/project/editor/target/shadow-cljs# ls
builds	       jar-manifest	   server.pid	      shadow-cljs.log.0
classpath.edn  logging.properties  server.stderr.log  shadow-cljs.log.0.lck
http.port      nrepl.port	   server.stdout.log  socket-repl.port
root@b4b33f696572:~/project/editor/target/shadow-cljs#

thheller10:01:11

anything in server.stderr.log or server.stdout.log?

mhuebert10:01:39

root@b4b33f696572:~/project/editor/target/shadow-cljs# cat server.stderr.log
shadow-cljs - HTTP server for ":live" available at 
root@b4b33f696572:~/project/editor/target/shadow-cljs# cat server.stdout.log
shadow-cljs - server running at 
shadow-cljs - nrepl running at /0.0.0.0:7888
root@b4b33f696572:~/project/editor/target/shadow-cljs#

mhuebert10:01:15

root@b4b33f696572:~/project/editor/target/shadow-cljs# curl 
<!DOCTYPE html>
<html lang="en"><head><link as="script" href="/js/ui.js" rel="preload"><title>shadow-cljs</title><style>body { font-size: 12px; font-family: Menlo, monospace; padding: 10px; margin: 0;</style></head><body><h1>shadow-cljs</h1><h2>Project: /root/project/editor</h2><ul><li><a href="/release-snapshots">Release Snapshots</a></li></ul><h2>HTTP Servers</h2><ul><li><a href="http://localhost:8701">http://localhost:8701 - :live</a></li></ul><div id="root"></div><script data-fn="shadow.cljs.ui.app.init" data-ref="none" type="shadow/run"></script><script defer src="/js/ui.js"></script></body></html>

thheller10:01:25

so the server is running

thheller10:01:53

and running npx shadow-cljs clj-eval '(+ 1 2)' probably works now

thheller10:01:38

ah it doesn't work since you still have the older version that kills the port file

mhuebert10:01:40

root@b4b33f696572:~/project/editor# npx shadow-cljs stop
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.140
shadow-cljs - server not running
root@b4b33f696572:~/project/editor# curl 
<!DOCTYPE html>
<html lang="en"><head><link as="script" href="/js/ui.js" rel="preload"><title>shadow-cljs</title><style>body { font-size: 12px; font-family: Menlo, monospace; padding: 10px; margin: 0;</style></head><body><h1>shadow-cljs</h1><h2>Project: /root/project/editor</h2><ul><li><a href="/release-snapshots">Release Snapshots</a></li></ul><h2>HTTP Servers</h2><ul><li><a href="http://localhost:8701">http://localhost:8701 - :live</a></li></ul><div id="root"></div><script data-fn="shadow.cljs.ui.app.init" data-ref="none" type="shadow/run"></script><script defer src="/js/ui.js"></script></body></html>

mhuebert10:01:02

i can upgrade there, one sec. on my mac i am using the latest v

thheller10:01:35

yeah the older version still kills the port file, so none of the later commands works

thheller10:01:38

shadow-cljs - socket connect failed, server process dead?
deleted pid file, please retry command to start new server

thheller10:01:44

newer version doesn't delete the file anymore

thheller11:01:48

see the start and then wait-for-server.sh which could probably just be sleep 1

thheller11:01:53

but that setup seems to work on circleci

thheller11:01:12

no idea about the mac stuff

mhuebert11:01:22

after updating, server starting seems to go on forever. i also tried rm -rf target

root@b4b33f696572:~/project/editor# npx shadow-cljs start
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - server starting .........................................................................................................................................................................................................................................................................................................................................

thheller11:01:52

it starts way slower due to no AOT

thheller11:01:05

what does the .log files say?

mhuebert11:01:23

i think it is stuck

thheller11:01:01

this is circleci now right? kinda confusing thinking about both setups

thheller11:01:26

the log files should at least say something

mhuebert11:01:22

oh, i see. the version deployed to maria on GH still has nrepl-port specified so in stderr we have:

[2018-01-28 11:01:13 - WARNING] TCP Port 9630 in use.
BindException: Address already in use (Bind failed)
	java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
	java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387)
	java.net.ServerSocket.bind (ServerSocket.java:375)
	java.net.ServerSocket.bind (ServerSocket.java:329)
	clojure.tools.nrepl.server/start-server (server.clj:149)
	clojure.tools.nrepl.server/start-server (server.clj:121)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:278)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:266)
but instead of throwing that error it keeps trying to start
shadow-cljs - server starting ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

mhuebert11:01:03

i thought putting a sleep command in between start & the command would be a fix for all of this, but my colleague (on mac os) still got that same error even with shadow-cljs start && sleep 2 && shadow-cljs clj-run ...

mhuebert11:01:21

(all of the stuff i am pasting now is circleci)

thheller11:01:02

can we please stick to debugging one thing at a time

thheller11:01:10

I doubt that the mac and circleci issues are related

thheller11:01:22

circleci I fixed by sleeping yes

thheller11:01:44

does that not work for you?

thheller11:01:09

if && don't work can you try multiple commands like in my circle config?

mhuebert11:01:02

on circleci i stopped using server or start entirely

mhuebert11:01:01

the reason i ssh’d into circleci was because it seemed like the same error

thheller11:01:33

on mac can you please delete target/shadow-cljs entirely, kill all java processes

thheller11:01:43

then run npx shadow-cljs start alone

thheller11:01:03

then run npx shadow-cljs clj-eval :foo

thheller11:01:14

not combined, after each other manually

mhuebert11:01:52

yes, that worked

thheller11:01:08

as does npx shadow-cljs stop?

thheller11:01:20

I mean the java process is properly killed?

thheller11:01:12

same deal, delete target/shadow-cljs, kill all java

thheller11:01:29

npx shadow-cljs start && npx shadow-cljs clj-eval :foo

thheller11:01:49

that causes the error immediately?

mhuebert11:01:21

mattpro:editor MattPro$ npx shadow-cljs start && npx shadow-cljs clj-eval :foo
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - server starting ................................................... ready!
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?

thheller11:01:53

now npx shadow-cljs clj-eval :foo alone works?

mhuebert11:01:55

however now i am able to npx shadow-cljs stop.

thheller11:01:59

ie. the server is running

mhuebert11:01:43

now that works yes

thheller11:01:12

I have no clue what is happening. the node process that starts the server waits until the port file appears

thheller11:01:19

the server writes the port file AFTER startup completed

mhuebert11:01:39

is writing the port file the very last thing it does?

thheller11:01:41

does it work if you reset everything and add the sleep?

thheller11:01:04

what I don't get is why it works on my machine. macOS version shouldn't make a difference

mhuebert11:01:13

adding a sleep 1 works for me now, but that is the same command that didn’t work for my colleague

thheller11:01:27

I'll just shuffle things arround a bit so that the node process waits a bit until after the file appears

thheller11:01:37

and maybe does a test run itself

thheller11:01:08

I have absolutely no other ideas

thheller11:01:32

what kind of hardware are you using? your colleague?

thheller11:01:59

maybe its just a timing issue?

mhuebert11:01:02

i’m not sure what his is. mine is a late 2013 macbook pro

thheller11:01:42

hmm I have the mid-2015 one, shouldn't be that much of a difference though

mhuebert11:01:34

i am not clear on the difference between what i get locally and the stuff i am replicating on circleci

mhuebert11:01:15

^^ there i am running shadow-cljs start and clj-eval as two separate commands (no sleep) and getting an error

thheller11:01:04

yes I have that happening in my circleci setup as well

mhuebert11:01:05

you could fork that repo & add to circleci to ssh in if you wanted to try other stuff (https://github.com/mhuebert/shadow-circleci) it is just a plain docker image with java+node+git

thheller11:01:24

thats why I added the wait-for-server.sh

thheller11:01:29

but thats just basically a sleep 1

mhuebert11:01:41

right. is what’s happening there different in some way from what happens on my machine?

thheller11:01:05

I have no idea

thheller11:01:10

there shouldn't be

thheller12:01:41

so it appears to work now on circleci

thheller12:01:20

will push a new version once I figure out how to configure npm on windows

thheller12:01:57

looks good now though, no sleep

thheller12:01:18

[email protected] should hopefully fix this

mhuebert12:01:28

:thumbsup::skin-tone-2:

mhuebert09:01:38

might be tomorrow, time zones..

eveko10:01:26

how do I fix require namespaces from cljsjs? I found out that I need to include a maping of a sort, but can't get it to work

eveko10:01:34

i am trying to get soda ash to work

eveko10:01:56

The required namespace "cljsjs.semantic-ui-react" is not available, it was required by "soda_ash/core.cljs".

eveko11:01:07

Į forgot to create the cljsjs folder ! It works now thanks for the link

hlolli14:01:15

has someone been able to connect to shadow-cljs nrepl connection with cider 0.17.0, I can connect but can't escape cider telling me that I'm not connected to cljs repl, I tried both cider-connect and cider-connect-clojurescript. Specifically I'm trying to connect to node-repl.

hlolli15:01:42

ah, this could be explained better to the manual, or I should have noticed it sooner. (shadow.cljs.devtools.api/nrepl-select :node-repl) node-repl is a node repl and the id of the build 🙂