hyperfiddle

2025-07-28T15:47:04.613069Z

hyperfiddle.rcf contains an https://github.com/hyperfiddle/rcf/blob/master/README.md#:~:text=(e/run%0A%20%20%20%20%20%20(let%20%5Bx%20(e/watch%20!x)%0A%20%20%20%20%20%20%20%20%20%20%20%20a%20(inc%20x)%0A%20%20%20%20%20%20%20%20%20%20%20%20b%20(inc%20x)%5D%0A%20%20%20%20%20%20%20%20(tap%20(%2B%20a%20b)))) of running Electric code in a test: >

(e/run
>       (let [x (e/watch !x)
>             a (inc x)
>             b (inc x)]
>         (tap (+ a b))))
But there's no e/run in v3. How to run tests in v3? Maybe someone has a link to examples?

oλv 2025-07-30T11:59:59.966699Z

(e/defn UserAgent [] (e/client (.-userAgent js/navigator)))
(e/defn OS [] (e/server (System/getProperty "os.name")))

(tests
  (with ((l/local {}
           (tap (e/server
                  (conj [(UserAgent)]
                        (OS)))))
         tap tap)))
Gives me
❌ FAIL in () (electric3-starter-app.main-test:50)
expected: (= % 3)
  actual: (not (= #error {
 :cause "EXCEPTION\nL47:22 electric3-starter-app.main-test/UserAgent\nclojure.lang.ExceptionInfo: definition called on a peer that doesn't support it"
 :via
 [{:type hyperfiddle.electric.impl.runtime3.proxy$java.lang.Exception$ff19274a
   :message "EXCEPTION\nL47:22 electric3-starter-app.main-test/UserAgent\nclojure.lang.ExceptionInfo: definition called on a peer that doesn't support it"}]
 :trace
 []} 3))
ERROR hyperfiddle.electric.impl.runtime3: #error {
 :cause definition called on a peer that doesn't support it
 :data {:args (#function[hyperfiddle.electric.impl.runtime3/cannot-resolve])}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message definition called on a peer that doesn't support it
   :data {:args (#function[hyperfiddle.electric.impl.runtime3/cannot-resolve])}
   :at [hyperfiddle.electric.impl.runtime3$cannot_resolve invokeStatic runtime3.cljc 1825]}]
 :trace
 [[hyperfiddle.electric.impl.runtime3$cannot_resolve invokeStatic runtime3.cljc 1825]
  [hyperfiddle.electric.impl.runtime3$cannot_resolve doInvoke runtime3.cljc 1825]
  [clojure.lang.RestFn invoke RestFn.java 411]
  [electric3_starter_app.main_test$UserAgent$fn__274118$fn__274119 invoke NO_SOURCE_FILE 47]
  [hyperfiddle.electric.impl.runtime3$invoke_with$fn__9949$fn__9950 invoke runtime3.cljc 320]
  [hyperfiddle.electric.impl.runtime3$_QMARK_swap_exception invokeStatic runtime3.cljc 308]
  [hyperfiddle.electric.impl.runtime3$_QMARK_swap_exception invoke runtime3.cljc 307]
  [hyperfiddle.electric.impl.runtime3$invoke_with$fn__9949 invoke runtime3.cljc 320]
  [clojure.lang.AFn applyToHelper AFn.java 154]
  [clojure.lang.RestFn applyTo RestFn.java 135]
  [clojure.core$apply invokeStatic core.clj 667]
  [clojure.core$apply invoke core.clj 662]
  [hyperfiddle.electric.impl.runtime3.CFAp$fn__9973 invoke runtime3.cljc 347]
  [hyperfiddle.electric.impl.runtime3.CFThunk$cr9926_block_0__9927 invoke runtime3.cljc 285]
  [cloroutine.impl$coroutine$fn__4598 invoke impl.cljc 61]
  [missionary.impl.Continuous step Continuous.java 153]
  [missionary.impl.Continuous transfer Continuous.java 339]
  [missionary.impl.Continuous$Process deref Continuous.java 34]
  [clojure.core$deref invokeStatic core.clj 2337]
  [clojure.core$deref invoke core.clj 2323]
  [hyperfiddle.incseq.fixed_impl$transfer$fn__8634$fn__8637 invoke fixed_impl.cljc 90]
  [hyperfiddle.incseq.fixed_impl$transfer$fn__8634 invoke fixed_impl.cljc 90]
  [hyperfiddle.incseq.fixed_impl$transfer invokeStatic fixed_impl.cljc 78]
  [hyperfiddle.incseq.fixed_impl$transfer invoke fixed_impl.cljc 71]
  [ deref fixed_impl.cljc 120]
  [missionary.impl.Propagator$5 refresh Propagator.java 744]
  [missionary.impl.Propagator transfer Propagator.java 552]
  [missionary.impl.Propagator$Subscription deref Propagator.java 107]
  [clojure.core$deref invokeStatic core.clj 2337]
  [clojure.core$deref invoke core.clj 2323]
  [hyperfiddle.electric.impl.runtime3$channel_transfer invokeStatic runtime3.cljc 1354]
  [hyperfiddle.electric.impl.runtime3$channel_transfer invoke runtime3.cljc 1328]
  [hyperfiddle.electric.impl.runtime3.Channel deref runtime3.cljc 1439]
  [missionary.impl.Propagator$4 refresh Propagator.java 664]
  [missionary.impl.Propagator transfer Propagator.java 552]
  [missionary.impl.Propagator$Subscription deref Propagator.java 107]
  [missionary.impl.Eduction pull Eduction.java 103]
  [missionary.impl.Eduction$2 invoke Eduction.java 131]
  [missionary.impl.Propagator stepAll Propagator.java 305]
  [missionary.impl.Propagator streamEmit Propagator.java 366]
  [missionary.impl.Propagator$4 tick Propagator.java 635]
  [missionary.impl.Propagator leave Propagator.java 402]
  [missionary.impl.Propagator ready Propagator.java 470]
  [missionary.impl.Propagator$1 invoke Propagator.java 490]
  [missionary.impl.Ambiguous$2 invoke Ambiguous.java 432]
  [missionary.impl.Observe$1 invoke Observe.java 86]
  [hyperfiddle.electric_local_def3$fn__16413$writer__16430$fn__16431 invoke electric_local_def3.cljc 57]
  [missionary.impl.Reduce transfer Reduce.java 33]
  [missionary.impl.Reduce ready Reduce.java 55]
  [missionary.impl.Reduce run Reduce.java 85]
  [missionary.core$reduce$fn__5071 invoke core.cljc 541]
  [missionary.core$attempt$fn__4956 invoke core.cljc 130]
  [missionary.impl.RaceJoin run RaceJoin.java 89]
  [missionary.core$race$fn__4953 invoke core.cljc 121]
  [missionary.core$absolve$fn__4967 invoke core.cljc 140]
  [electric3_starter_app.main_test$eval274767 invokeStatic NO_SOURCE_FILE 50]
  [electric3_starter_app.main_test$eval274767 invoke NO_SOURCE_FILE 50]
  [clojure.lang.Compiler eval Compiler.java 7700]
  [nrepl.middleware.interruptible_eval$evaluator$run__163890$fn__163901 invoke interruptible_eval.clj 106]
  [nrepl.middleware.interruptible_eval$evaluator$run__163890 invoke interruptible_eval.clj 101]
  [nrepl.middleware.session$session_exec$session_loop__164164 invoke session.clj 230]
  [nrepl.SessionThread run SessionThread.java 21]]}
#error {
 :cause EXCEPTION
L47:22 electric3-starter-app.main-test/UserAgent
clojure.lang.ExceptionInfo: definition called on a peer that doesn't support it
 :via
 [{:type hyperfiddle.electric.impl.runtime3.proxy$java.lang.Exception$ff19274a
   :message EXCEPTION
L47:22 electric3-starter-app.main-test/UserAgent
clojure.lang.ExceptionInfo: definition called on a peer that doesn't support it}]
 :trace
 []}

oλv 2025-07-30T12:01:36.512799Z

Can we do arbitrary browser-stuff in e/client or is there some limit? I seem to only be able to return stuff thinking-face

xificurC 2025-07-30T12:02:33.502589Z

a local test, when run on the JVM, runs both server and client on the JVM

2025-07-30T12:02:36.890409Z

@post972 I got this error 'definition called on a peer that doesn't support it' when I sent JS interop code to CLJ REPL Make sure you have CLJS REPL, not only CLJ, and send JS interop code only to CLJS REPL. JVM interop only to CLJ REPL I use Emacs + Cider, can share my config

xificurC 2025-07-30T12:03:25.535739Z

you're mixing JVM and JS interop in a single test. The local test entrypoint operates on a single host, JVM or JS

oλv 2025-07-30T12:03:40.616139Z

Alright, I see 😄

oλv 2025-07-30T12:04:31.225569Z

So we can test JS-Electric and JVM-Electric, but as of now no cross-site tests?

oλv 2025-07-30T12:04:54.260639Z

@shkertik Please do 🤓

xificurC 2025-07-30T12:05:55.949919Z

correct. We don't have unit tests that run the full stack. Could we even get away with calling that a unit test? think_beret

oλv 2025-07-30T12:06:51.424399Z

I don't think so :^)

2025-07-30T12:08:22.188019Z

@post972 do you need the full setup - how to launch Electric project straight from CIDER, or just the code for sending sexps to different REPLs?

oλv 2025-07-30T12:09:38.806319Z

I'm happy launching with bb dev

oλv 2025-07-30T12:09:51.686819Z

But I'm interested in how to send to different REPLs

2025-07-30T12:13:32.790259Z

This code relies on having 2 REPLs connected to a single CIDER session. I start with cider-jack-in-clj, then after it's loaded I do cider-connect-sibling-cljs

(defun eval-last-sexp-in-specific-repl (repl-type)
  "Evaluate the last expression only in the 'clj or 'cljs REPL."
  (interactive)
  (let ((form (cider-last-sexp))
        (cljs-conn (cider-current-connection repl-type)))
    (when (and form cljs-conn)
      (nrepl-request:eval form
                          (cider-interactive-eval-handler)
                          cljs-conn))))

(defun eval-last-sexp-in-clj ()
  "Evaluate the last expression only in the Clojure (not CLJS) REPL."
  (interactive)
  (eval-last-sexp-in-specific-repl 'clj))

(defun eval-last-sexp-in-cljs ()
  "Evaluate the last expression only in the ClojureScript REPL."
  (interactive)
  (eval-last-sexp-in-specific-repl 'cljs))

(define-key cider-mode-map (kbd "C-M-") 'eval-last-sexp-in-clj)
(define-key cider-mode-map (kbd "C-S-") 'eval-last-sexp-in-cljs)

oλv 2025-07-30T12:14:27.863809Z

oooo

oλv 2025-07-30T12:14:29.255459Z

👀

2025-07-30T12:17:27.812299Z

You can check that you have proper connections with sesman-browser, it should look like this: > CIDER Sessions: > > 1: dev/kombinacija:localhost:43405 > linked-to: proj(/mnt/sda2/projects/dev/kombinacija/) > objects: cider-repl %s(clj) cider-repl %s(cljs:shadow)

oλv 2025-07-30T12:18:12.189439Z

Ahh doesn't work for me unfortunately, I connect with cider-connect-clj&cljs

oλv 2025-07-30T12:20:50.702109Z

Do you know what I'm supposed to answer to this prompt?

2025-07-30T12:23:03.812379Z

cider-connect-clj&cljs is essentially the same as cider-connect-clj followed by cider-connect-sibling-cljs. It also didn't work for me, because there's a lag before CLJ REPL fully starts, and CLJS REPL can't connect properly. When you run cider-connect-clj&cljs there's no pause, and CLJS isn't properly attached to sesman session. Try cider-connect-clj , check that Electric site is running fine, then cider-connect-sibling-cljs

oλv 2025-07-30T12:24:22.710789Z

I don't want to jack in, I'm happy with bb dev. I'll try connecting in two steps though 😄

oλv 2025-07-30T12:25:32.527059Z

What am i supposed to answer to this prompt thinking-face

2025-07-30T12:25:57.000669Z

REPL type is shadow

oλv 2025-07-30T12:26:25.486429Z

Ahh, sweet

oλv 2025-07-30T12:26:31.878409Z

It's working now 😎

🤝 1
oλv 2025-07-30T12:30:49.381539Z

Thanks for the help! @shkertik

❤️ 1
xificurC 2025-07-28T15:50:08.805209Z

https://github.com/hyperfiddle/electric/blob/master/test/hyperfiddle/electric3_test.cljc l/single for a single peer test, l/local for a 2-peer (client/server) but local test (both peers on same host)

🙏 3