Fork me on GitHub
#shadow-cljs
<
2018-02-28
>
lilactown02:02:38

is there a way to re-use the shadow-cljs server, and use the lein integration?

sparkofreason02:02:11

Rolled back to the version of shadow-cljs.edn that was working before, still getting the same behavior.

sparkofreason02:02:56

Getting weirder - running lein clean fixed the version without lein.

thheller08:02:33

@dave.dixon socket connect failed, server process dead? means that the server was most likely killed forcefully so the server didn't clean up after itself. can you verify that the server is actually dead? ie. no running java process left?

thheller08:02:18

lein clean will delete the target folder which includes target/shadow-cljs/*.port

thheller08:02:41

the script uses those files to decide whether it should start a new server or connect to old one

thheller08:02:59

I should add a command to delete those files

thheller08:02:41

@lilactown re-use server? all commands works identically with or without lein

thheller08:02:06

just don't run lein clean since that kills the information the server needs

thheller08:02:21

or set :cache-root ".shadow-cljs" in your config so lein clean doesn't mess with the server state

thheller08:02:46

which is a default I should probably change anyways

mitchelkuijpers10:02:53

@hlolli not sure if i understand correctly but we run shadow-cljs like this:

(defn start-cljs-repl []
  (shadow-server/start!)
  (shadow/watch :app)
  (shadow/watch :test)
  (shadow/watch :devcards)
  (shadow/nrepl-select :app))
and then we can just do cider-jack-in-clojurescript We also have a .dir-locals.el which contains:
((nil . ((projectile-project-type . lein-test)
         (eval . (progn
                   (require 'cider)
                   (setq projectile-create-missing-test-files t)
                   (setq cider-cljs-lein-repl "(start-cljs-repl)"))))))
So we can set the correct command to start he cljs-repl

thheller10:02:59

@mitchelkuijpers I think the issue is that you can't yet do this with node-repl

hlolli12:02:39

very neat! @mitchelkuijpers I'm stealing that for my non-node projects 🙂

thheller17:02:19

I just pushed 2.2.0. bumped to 2.2 because I changed the default cache directory. it is now .shadow-cljs instead of target/shadow-cljs. too many conflicts with lein cleaning the target directory. you can configure the old directory by setting :cache-root "target/shadow-cljs" in your config.

thheller17:02:43

(shadow.cljs.devtools.api/node-repl) also works inside nrepl now

thheller17:02:32

also added shadow-cljs browser-repl (or (shadow.cljs.devtools.api/browser-repl) for a simple browser REPL without a build config

sparkofreason18:02:18

Tried updating to 2.2.0, still getting the issue where it immediately exits. Looking at the code it wasn't clear what would happen if cp/spawnSync failed before the process got started, i.e. if an error would be displayed. It seems like this is always failing for me, independent of lein, since it also failed to run an npm command it said it was executing.

levitanong20:02:58

Tried it as well. Now getting “cannot call a class as a function” error on an npm require. After a lein clean and downgrade back to 2.1.26, the issue disappears.

thheller21:02:44

it should work if you add [com.google.javascript/closure-compiler-unshaded "v20180101"] to your dependencies

thheller21:02:13

@dave.dixon just calling lein with-profile dev run -m shadow.cljs.devtools.cli --npm watch app directly also fails without any error?

sparkofreason21:02:11

No, directly calling the printed command works.

thheller21:02:26

you are on windows with which node version?

hlolli21:02:06

I'm noticing, no matter how I kill shadow-cljs process within emacs the file nrepl.port isn't always deleted causing shadow-cljs - socket connect failed, server process dead?, I wonder if it's sending some kill signal that isn't handled by shadow-cljs?

thheller21:02:35

no kill signals are handled by shadow-cljs since java doesn't support that

thheller21:02:54

what does emacs do with the process?

sparkofreason21:02:58

Windows 10, node 8.9.4

hlolli21:02:23

I've tried two things (process-send-string (get-process "shadow-cljs") ":repl/quit\n") and (kill-process "shadow-cljs") it kills the process for sure, it may be sending some SIGTERM or SIGINIT, I wonder which or something else...

hlolli21:02:12

well, being a hacker, I can trigger emacs to delete these files on process kill...

thheller21:02:43

are you sure the process is actually dead?

thheller21:02:51

because the shadow-cljs process is the node process

thheller21:02:03

it has a java child process

hlolli21:02:58

hmmm, I actually look for java, I wonder if my gnome-system-moniter isn't showing it, due to being nested within emacs...

hlolli21:02:42

but node should be able to listen to SIGTERM signals, so you can add some java process kill callbacks

thheller21:02:32

@dave.dixon just reproduced the problem on my machine. I only ever started it via WSL bash so I never noticed it before

thheller21:02:36

will look into it

sparkofreason22:02:02

@thheller Had some weird problem getting node to update shadow-cljs, but once I got past that it worked. Thanks for the quick fix.