shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
2020-12-16T15:09:20.458200Z

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.

2020-12-16T15:09:45.458600Z

For instance, I get the following in Cursive nREPL:

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

2020-12-16T15:10:03.458900Z

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)

2020-12-16T15:10:43.459200Z

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

2020-12-16T15:12:19.460200Z

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
--------------------------------------------------------------------------------

rgm 2020-12-16T15:30:01.465500Z

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).

thheller 2020-12-16T16:08:43.465900Z

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

thheller 2020-12-16T16:09:34.466300Z

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

❤️ 1
rgm 2020-12-16T16:10:43.467200Z

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

thheller 2020-12-16T16:11:07.467600Z

mostly GCC yes

rgm 2020-12-16T16:11:32.468400Z

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

thheller 2020-12-16T16:12:49.468900Z

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

thheller 2020-12-16T16:13:13.469200Z

but most modern language features can be compiled down

2020-12-16T16:19:20.470100Z

@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 <http://localhost:3500>
shadow-cljs - HTTP server available at <http://localhost:3600>
shadow-cljs - server version: 2.11.8 running at <http://localhost:9630>
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
+ shadow-cljs@2.11.8
updated 1 package in 5.141s

thheller 2020-12-16T16:21:01.470500Z

server version: 2.11.8 looks fine yeah

thheller 2020-12-16T16:21:28.471Z

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

thheller 2020-12-16T16:21:54.471400Z

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

2020-12-16T16:23:15.472500Z

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?

thheller 2020-12-16T16:24:37.473100Z

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

thheller 2020-12-16T16:24:55.473500Z

clj -m shadow.nrepl-debug 3000 3001

thheller 2020-12-16T16:25:08.473900Z

tunnels from port 3000 to port 3001

thheller 2020-12-16T16:25:43.474600Z

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

2020-12-16T16:29:09.474800Z

Ok, I got that running\

2020-12-16T16:29:33.475300Z

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

thheller 2020-12-16T16:33:08.475700Z

it logs somewhere in target/nrepl-debug or so

thheller 2020-12-16T16:33:10.475900Z

the file would help

2020-12-16T16:33:45.476400Z

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
=&gt; [:selected :client]
(+ 1 2)
Timeout while waiting for result.
(+ 1 2)
Timeout while waiting for result.
(+ 1 2)
Timeout while waiting for result.

2020-12-16T16:34:07.476500Z

thheller 2020-12-16T16:56:32.476900Z

thanks. I'll take a look

👍 1
thheller 2020-12-16T18:10:40.478100Z

@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

2020-12-16T18:15:33.478400Z

nothing like that, I was not using any debugger

2020-12-16T18:15:41.478600Z

the app was running fine

thheller 2020-12-16T18:17:37.478900Z

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

thheller 2020-12-16T18:18:16.479300Z

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

2020-12-16T18:19:37.480Z

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