Fork me on GitHub
#shadow-cljs
<
2020-12-16
>
Pavel Klavík15:12:20

Hi, it happens to me quite frequently (several times every day) that while doing changes in the code, Shadow-cljs REPL stops working correctly and I have to restart Shadow to make it working again.

Pavel Klavík15:12:45

For instance, I get the following in Cursive nREPL:

(clojure.string/join ["ab" "cd"])
Timeout while waiting for result.

Pavel Klavík15:12:03

And shadow-cljs outputs this into console:

[2020-12-16 16:07:58.625 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 71}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/fn--15184/fn--15187 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        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 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)

Pavel Klavík15:12:43

Any idea what could be causing this or how I could debug where is the problem?

Pavel Klavík15:12:19

Also, all previous requires are lost when this happens. So for instance, I run the following code before:

(require '[orgpad.client.db.get :as db-get])
=> nil
I can use functions from db-get perfectly fine. After this, I can't call them and I get this error in REPL:
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:2
 No such namespace: db-get, could not locate db_get.cljs, db_get.cljc, or JavaScript source providing "db-get" (Please check that namespaces with dashes use underscores in the ClojureScript file name)
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var db-get/latest-editor
--------------------------------------------------------------------------------

rgm15:12:01

I have a client who wants to re-add limited IE11 support to an app. One technical problem is that we’re leaning on Vega for charting. Vega has switched over to a lot of spread / gather and arrow function syntax and relies on Symbols extensively. Am I understanding the shadow-cljs docs right that any npm dependencies it processes into the app bundle get ES5'd? Wondering if this is a reasonable enough way to get it to at least compile for loading into IE11. (I’m presuming there are still going to be runtime breakages that I can at least catch as exceptions and use to swap in a degraded UI).

thheller16:12:43

@pavel.klavik which version? this should have been fixed a couple versions ago

thheller16:12:34

@rgm the default is ES5 output so that should already work

❤️ 3
rgm16:12:43

Is this some kind of personal sorcery, or just what GCC does?

thheller16:12:07

mostly GCC yes

rgm16:12:32

Either way this beats heading into webpack/babel and foreign libs 🙏

thheller16:12:49

well can't know for sure. sometimes some patterns aren't properly detected/polyfilled by GCC and need manual tuning

thheller16:12:13

but most modern language features can be compiled down

Pavel Klavík16:12:20

@thheller It seems that I am already running the latest version:

shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
NPM dependency "react" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.8 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
But I updated anyway using npm install -g shadow-cljs where I got
+ [email protected]
updated 1 package in 5.141s

thheller16:12:01

server version: 2.11.8 looks fine yeah

thheller16:12:28

I'm not sure what could be causing this. I was not able to reproduce it again after the last fix

thheller16:12:54

would help to know what else is going on over the nrepl connection and at what point it starts failing

Pavel Klavík16:12:15

I am not able to find a reproducible way yet. It occurs several times per day to be quite annoying but not enough frequently to be easily reproducible. Is there some debugging I could run when it occurs?

thheller16:12:37

I wrote a nrepl helper that logs all the messages back and forth, would help to have a dump from that

thheller16:12:55

clj -m shadow.nrepl-debug 3000 3001

thheller16:12:08

tunnels from port 3000 to port 3001

thheller16:12:43

so clj -m shadow.nrepl-debug 9001 9000 would work if you then connect your editor to 9001 instead of 9000

Pavel Klavík16:12:09

Ok, I got that running\

Pavel Klavík16:12:33

what would you want to get when it fails? the console output, or the debug message is stored somewhere else?

thheller16:12:08

it logs somewhere in target/nrepl-debug or so

thheller16:12:10

the file would help

Pavel Klavík16:12:45

Ok, I actually got it failing right now, with

Connecting to remote nREPL server...
Clojure 1.10.1
(shadow/repl :client)
To quit, type: :cljs/quit
=> [:selected :client]
(+ 1 2)
Timeout while waiting for result.
(+ 1 2)
Timeout while waiting for result.
(+ 1 2)
Timeout while waiting for result.

thheller16:12:32

thanks. I'll take a look

👍 3
thheller18:12:40

@pavel.klavik can't tell anything from the logs. this is a browser env right? is the browser maybe on a breakpoint in the debugger? break on uncaught exception or something? or js/alert? dunno why else it wouldn't respond to a simple eval

Pavel Klavík18:12:33

nothing like that, I was not using any debugger

Pavel Klavík18:12:41

the app was running fine

thheller18:12:37

guess I'll add some more logging to help figure this out

thheller18:12:16

oh one idea. do you have an actual cljs/user.cljs file on the classpath?

Pavel Klavík18:12:37

There are clj/user.clj files generated by Luminus template, but certainly nothing like that. All my ns start with orgpad