This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-06
Channels
- # announcements (3)
- # architecture (16)
- # beginners (5)
- # cherry (1)
- # cider (3)
- # cljsrn (2)
- # clojure (54)
- # clojure-dev (11)
- # clojure-europe (14)
- # datalevin (26)
- # emacs (8)
- # helix (5)
- # honeysql (5)
- # hyperfiddle (40)
- # lsp (12)
- # malli (23)
- # missionary (7)
- # nrepl (2)
- # off-topic (18)
- # releases (2)
- # yamlscript (1)
What's the newest JDK version I can build Electric with safely via Docker? Any benefits to newer versions, e.g. performance? Starter app Dockerfile uses OpenJDK 11 and runs with Amazon Corretto 11: https://github.com/hyperfiddle/electric-starter-app/blob/main/Dockerfile
Electric app runs locally via REPL & builds via Docker but when I try to build uberjar on host or via Docker, I get this exception about a Protocol:
Exception in thread "main" java.lang.NoClassDefFoundError: myproject/proto/AMyProto
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1022)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
...
Caused by: java.lang.ClassNotFoundException: myproject.proto.AMyProto
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
... 114 more
prod.clj
has (:gen-class)
another gen-class issue? AOT?
;; proto:
(defprotocol AMyProto
(do-thing [this ...])
...)
;; mock file:
(ns mymock
(:require [myproject.proto :as proto]))
(defrecord MyImpl [!history secret-token] ;; access token?
proto/AMyProto
(do-thing [this ...] ...))
Hmm, any ideas? Could it be JDK version issue?Tried adding (:gen-class)
to myproject.proto
namespace, but no luck.
also happens on host machine that's running Java Oracle 20.0.01
Requiring myproject.proto
NS from prod.clj does not help
this is not an electric issue
did you resolve it?
No 😕 Temporary workaround by deploying dev build to prod
this is likely the root problem causing the rest of your problems
my pain is no logs
just reactorfailure
logs are not broken, please check out a clean starter app and convince yourself they work
you can add more logs to your app's boot sequence
I compared mine to the starter-app and seems to be same
you can also turn log level up to trace
ok will try that
maybe I need to catch exception in jetty side
i want to be clear: if logs are broken, it is your fault
sure, but I've had logging issues before so I'd rather mention it than be stuck for hours
Electric Does Not Have Logging Issues, if you suspect otherwise please checkout a clean starter app and confirm that it is true, and save yourself the hours of pain debugging something that is not broken
ok - just trying to get things working 🙂
How should I prevent deployment if RCF tests fail? Does someone have a Github Actions or Dokku template lying around?
https://github.com/hyperfiddle/electric/blob/master/.github/workflows/test_and_deploy.yml
ReactorFailure on prod uberjar build, but works fine in REPL build. No errors in server logs - only client.
Connecting...
main.9BFB58C0E5DF4F15F4C87A7ED5236453.js:1522 Connected.
main.9BFB58C0E5DF4F15F4C87A7ED5236453.js:1419 WebSocket is already in CLOSING or CLOSED state.
Reactor failure:
"Remote error - 1011 org.eclipse.jetty.websocket.core.exception.WebSocketException:
Error: Remote error - 1011 org.eclipse.jetty.websocket.core.exception.WebSocketException: WebSocketAdapter$WebSocketPingPongListener$12d400b6 OPEN met
at new Tm ()
at Wm ()
at Vm ()
at p ()
at Function.t [as o] ()
at lT ()
at e.resume ()
at lT ()
at e.resume ()
at mU ()"
logback.xml:
<!-- Jetty logger config. See and
ask ChatGPT. `scan` and `scanPeriod` enable hot reload of logger config, leave on! -->
<configuration scan="true" scanPeriod="5 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%-5level) %logger: %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="hyperfiddle" level="DEBUG" additivity="false"><appender-ref ref="STDOUT" /></logger>
<!-- <logger name="hyperfiddle.electric.impl.io" level="INFO" additivity="false"><appender-ref ref="STDOUT" /></logger> -->
<logger name="quey" level="DEBUG" additivity="false"><appender-ref ref="STDOUT" /></logger>
</configuration>
@U09K620SG I've added an nREPL into my uberjar build. How do I trigger an Electric run from REPL to try and see an error, please? (e/run something)
?
this doesn't seem to work:
(ns scratch
(:require [hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2 :as dom]))
(e/defn Test []
(dom/div "hi"))
(e/run (Test.))
OK this runs "in prod" but obviously fails because DOM stuff missing on server for my components:
(ns scratch
(:require [hyperfiddle.rcf :as rcf :refer (tests tap %)]
[hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2 :as dom]
[missionary.core :as m]
[hyperfiddle.history :as history];; for core
[quey.manage.core :as core]
[datomic.api :as d]))
(e/defn SanityTest [!x]
(prn "hi")
(let [x (e/watch !x) ; reactive x
a (inc x)] ; reactive a depends on reactive x
(tap (+ a (inc x)))))
;(d/q nil nil))
;(e/run Test)
(tests "Electric baseline program - a dataflow diamond"
(def dispose (e/run (core/Page. [:thing]))) ;; fails because DOM stuff
;; rest is jsut here to test
(def !x (atom 0))
(def dispose (e/run (SanityTest. !x)))
% := 2
(swap! !x inc)
% := 4
(swap! !x inc)
% := 6
(dispose))
For me, this error was caused by requiring xtdb.api
or anything that requires xtdb.api
in user.clj
. Similarly, at dev/repl time, this was not an issue, but occurred only with uberjars. Requiring xtdb.api
(or anything that requires it) in prod.clj was not a problem.
I was able to work around it by avoiding requiring utils/start-xtdb!
in user.clj and instead doing (def start-xtdb! (delay @(requiring-resolve 'utils/start-xtdb!)))
.
It was really hard to track down, had to do a full "binary search" on my code vs the electric-starter-app code.
@U09K620SG FYI
@U5S5570KH I can’t remember but try moving user.clj
footgun to ~/src-dev
and adding “src-dev”
to :paths for :dev
alias.
Yeah. I think this resolved a different error, but maybe it helps: https://www.karimarttila.fi/clojure/2023/03/14/creating-uberjar-for-clojure-fullstack-app.html
I had to resort to deploying a dev build because I can't get uberjar working (ReactorFailure - zero server logs). How can I hide the shadow-cljs thingy until I can fix?
I am trying to get only the first value of a flow. I am currently doing something like this:
(->> (e/fn [] (e/server (:task/toggled (d/entity db task-id))))
(m/eduction (filter boolean?))
(m/reductions conj [])
new
first)
This feels roundabout, as the rest of the flow still is received, only to be discarded (maybe that's okay). Is there a better way to do this?use e/watch to bridge atoms to electric, which you already know, i think you might be over thinking it
(e/server (println (e/client (e/watch !x)))) accomplishes your goal of running an effect on the server every time an atom changes
oops, did you delete a question? or somehow i replied to wrong thread