Fork me on GitHub
#calva
<
2023-04-02
>
Dustin Getz12:04:08

From calva only, I get a shadow-cljs error when starting shadow from inside a vanilla deps repl (NOT a calva-enriched shadow-cljs repl). It's not deterministic, sometimes the shadow build succeeds. And the error changes. Running the same main function from a terminal succeeds deterministically always. Any ideas what could cause this?

; Syntax error compiling at (clojure/core/async.clj:463:21).
; No such var: ioc/state-machine
Note that my project does not depend on core.async, this is a shadow stack frame

Dustin Getz12:04:00

We are loading shadow like this:

(ns user
  ; For fastest REPL startup, no heavy deps here, REPL conveniences only
  ; (Clojure has to compile all this stuff on startup)
  (:require [missionary.core :as m]
            hyperfiddle.rcf))

; lazy load dev stuff - for faster REPL startup and cleaner dev classpath
(def shadow-start! (delay @(requiring-resolve 'shadow.cljs.devtools.server/start!)))
(def shadow-watch (delay @(requiring-resolve 'shadow.cljs.devtools.api/watch)))
(def shadow-compile (delay @(requiring-resolve 'shadow.cljs.devtools.api/compile)))
(def shadow-release (delay @(requiring-resolve 'shadow.cljs.devtools.api/release)))
(def start-electric-server! (delay @(requiring-resolve 'electric-server-java8-jetty9/start-server!)))
(def rcf-enable! (delay @(requiring-resolve 'hyperfiddle.rcf/enable!)))
and then
(defn main [& args]
  (println "Starting Electric compiler and server...")
  (@shadow-start!) 
  ...

Dustin Getz12:04:14

It seems like a nondeterministic classpath issue

Dustin Getz12:04:18

I considered if it could be a shadow-cljs state problem (perhaps due to killing the calva repl terminal with C-C), but the error suggests classpath issue not state issue

phill17:04:10

Downgrade core.async

Dustin Getz17:04:04

Do you recognize the issue? We don't use core.async, this is a transitive dependency from shadow; googling the error doesn't turn up much

pez22:04:19

> killing the calva repl terminal with C-C What does this mean?

Dustin Getz22:04:10

i restart the clj repl with ctrl-C in the terminal that hosts the repl

pez22:04:04

What does a Calva REPL session look like? Can you describe? I’m not quite following.

pez22:04:00

Since it works at a regular REPL, but not via Calva, I wonder if it could be an nREPL thing. See if you can reproduce the problem with a sever started like Calva starts it (there’s a command for copying out the Jack-in command line) and an nrepl client like repl-y or even lein repl :connect. (Which I think might use repl-y anyway.)

👀 2
Dustin Getz22:04:10

ok, my current hypothesis is yes it would, i am guessing classpath nondeterminism resolving core.async from both cider-nrepl(?) and shadow

Dustin Getz22:04:17

haven’t looked into it yet

phill08:04:45

I suspect a race condition. The symptomatic message is reminiscent of https://ask.clojure.org/index.php/12690/can-async-248-be-reverted which links to https://clojure.atlassian.net/browse/ASYNC-249

👀 2
👍 2
phill08:04:50

(If it's the right "http://ask.clojure.org" ask, it could stand an upvote)