Fork me on GitHub
#hyperfiddle
<
2023-03-15
>
Michael W00:03:04

I upgraded to the latest master sha and am now seeing errors like this for portal:

The required JS dependency "http" is not available, it was required by "portal/runtime/node/launcher.cljs".

Dependency Trace:
	user.cljs
	app/tic_tac_toe.cljc
	portal/api.cljc
	portal/runtime/node/launcher.cljs

Searched for npm packages in:
	/home/mwhitford/clojure/electric-ttt/node_modules
http is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.

	npm install --save-dev shadow-cljs
I did not change anything, and yarn shows shadow-cljs in devDependencies and installed.

2
Michael W02:03:33

I was able to get this working again by adding the following dep to deps.edn:

http-kit/http-kit {:mvn/version "2.7.0-alpha4"}
Not sure why it stopped loading it as a dep from portal, it's in the deps.edn for portal....

Michael W02:03:56

Spoke too soon, that cleared the issue when loading a file into the repl, but the electric compile is still failing with the same above error.

👀 2
Dustin Getz02:03:06

we will take a look in the morning. i think we removed our dependency on npm’s shadow entirely, the error (from portal?) suggests that perhaps shadow-cljs must be listed as a normal dependency in node modules? i think this is a portal question

Dustin Getz02:03:00

scan the last 20 commits on electric github and you might see we removed shadow from package.json or similar

Michael W02:03:25

I'll look thanks for the pointer.

Yab Mas17:03:18

Im running into an issue while trying to add the electric-ws-handler to my own server-setup. I wouldn't be suprised if Im doing something basic wrong, but the error seems to be inline with what I see in the source-code but I dont fully understand it so Im posting here. Im not concerned with java 8 compatibility so upgraded to jetty9-adapter and basically followed the example in the electric-jetty-server ns. When I load the page in the browser it seems to crash on-connect with the followin error: Wrong number of args (2) passed to: hyperfiddle.electric-jetty-adapter/electric-ws-message-handler With the last bit of the trace being: [clojure.lang.AFn throwArity AFn.java 429] [clojure.lang.AFn invoke AFn.java 36] [hyperfiddle.electric_jetty_adapter$electric_ws_adapter$on_connect__23415 invoke electric_jetty_adapter.clj 57] Looking at the source-code of electric-ws-adapter I indeed see that handler-f is called with 2 args and electric-ws-message-handler expects 3, but I rreally dont understand most of the code there. Any clue whats going on? I'll post source-code and client/server errors in comments

2
Yab Mas17:03:10

(defn wrap-websocket [next-handler ws-handler]
  (fn [request]
    (if (jetty/ws-upgrade-request? request)
      (jetty/ws-upgrade-response ws-handler)
      (next-handler request))))

(defn app [{:keys [routes
                   custom-content-negotiation
                   ws-handler
                   jira-handlers]}]
  (let [content-negotiation (muuntaja-options custom-content-negotiation)]
    (->
      (ring/ring-handler
        (ring/router
          [routes
           (atlassian-connect/routes jira-handlers)])
        (constantly not-found-response))
      (middleware/wrap-format content-negotiation)
      (catch-req-middleware)
      (wrap-params)
      (wrap-resource "public")
      (wrap-content-type)
      (wrap-index-as-root)
      (wrap-websocket ws-handler))))

(defn start-server
  [{:keys [port]
    :as server-config}]
  (println (str "\nStarting server on port: " port "\n"))
  (jetty/run-jetty
    (app server-config)
    {:port port
     :join? false}))

Yab Mas17:03:55

From different ns:

(def server-config
  {:port (server/get-port "electric")
   :ws-handler (adapter/electric-ws-adapter adapter/electric-ws-message-handler)})

(defn start-server [] (server/start-server server-config))

Yab Mas17:03:06

ERROR hyperfiddle.electric-jetty-adapter: Websocket error #error {
 :cause Wrong number of args (2) passed to: hyperfiddle.electric-jetty-adapter/electric-ws-message-handler
 :via
 [{:type org.eclipse.jetty.websocket.api.exceptions.CloseException
   :message org.eclipse.jetty.websocket.core.exception.WebSocketException: WebSocketAdapter$WebSocketPingPongListener$12d400b6 OPEN method error: Wrong number of args (2) passed to: hyperfiddle.electric-jetty-adapter/electric-ws-message-handler
   :at [org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler convertCause JettyWebSocketFrameHandler.java 506]}
  {:type org.eclipse.jetty.websocket.core.exception.CloseException
   :message org.eclipse.jetty.websocket.core.exception.WebSocketException: WebSocketAdapter$WebSocketPingPongListener$12d400b6 OPEN method error: Wrong number of args (2) passed to: hyperfiddle.electric-jetty-adapter/electric-ws-message-handler
   :at [org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession lambda$onOpen$5 WebSocketCoreSession.java 404]}
  {:type org.eclipse.jetty.websocket.core.exception.WebSocketException
   :message WebSocketAdapter$WebSocketPingPongListener$12d400b6 OPEN method error: Wrong number of args (2) passed to: hyperfiddle.electric-jetty-adapter/electric-ws-message-handler
   :at [org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler onOpen JettyWebSocketFrameHandler.java 187]}
  {:type clojure.lang.ArityException
   :message Wrong number of args (2) passed to: hyperfiddle.electric-jetty-adapter/electric-ws-message-handler
   :at [clojure.lang.AFn throwArity AFn.java 429]}]
 :trace
 [[clojure.lang.AFn throwArity AFn.java 429]
  [clojure.lang.AFn invoke AFn.java 36]
  [hyperfiddle.electric_jetty_adapter$electric_ws_adapter$on_connect__23415 invoke electric_jetty_adapter.clj 57]
  [ring.adapter.jetty9.websocket$proxy_ws_adapter$fn__2484 invoke websocket.clj 153]
  [ring.adapter.jetty9.websocket.proxy$org.eclipse.jetty.websocket.api.WebSocketAdapter$WebSocketPingPongListener$12d400b6 onWebSocketConnect nil -1]
  [org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler onOpen JettyWebSocketFrameHandler.java 177]
  [org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession lambda$onOpen$6 WebSocketCoreSession.java 410]
  [org.eclipse.jetty.server.handler.ContextHandler handle ContextHandler.java 1463]
  [org.eclipse.jetty.server.handler.ContextHandler handle ContextHandler.java 1482]
  [org.eclipse.jetty.websocket.core.server.internal.AbstractHandshaker$1 handle AbstractHandshaker.java 212]
  [org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession onOpen WebSocketCoreSession.java 410]
  [org.eclipse.jetty.websocket.core.internal.WebSocketConnection onOpen WebSocketConnection.java 542]
  [org.eclipse.jetty.io.AbstractEndPoint upgrade AbstractEndPoint.java 451]
  [org.eclipse.jetty.server.HttpConnection upgrade HttpConnection.java 419]
  [org.eclipse.jetty.server.HttpConnection onCompleted HttpConnection.java 450]
  [org.eclipse.jetty.server.HttpChannel onCompleted HttpChannel.java 968]
  [org.eclipse.jetty.server.HttpChannel handle HttpChannel.java 485]
  [org.eclipse.jetty.server.HttpConnection onFillable HttpConnection.java 282]
  [org.eclipse.jetty.io.AbstractConnection$ReadCallback succeeded AbstractConnection.java 319]
  [org.eclipse.jetty.io.FillInterest fillable FillInterest.java 100]
  [org.eclipse.jetty.io.SelectableChannelEndPoint$1 run SelectableChannelEndPoint.java 53]
  [org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy runTask AdaptiveExecutionStrategy.java 412]
  [org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy consumeTask AdaptiveExecutionStrategy.java 381]
  [org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy tryProduce AdaptiveExecutionStrategy.java 268]
  [org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy lambda$new$0 AdaptiveExecutionStrategy.java 138]
  [org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread run ReservedThreadExecutor.java 407]
  [org.eclipse.jetty.util.thread.QueuedThreadPool runJob QueuedThreadPool.java 894]
  [org.eclipse.jetty.util.thread.QueuedThreadPool$Runner run QueuedThreadPool.java 1038]
  [java.lang.Thread run Thread.java 833]]}

Dustin Getz17:03:22

Can you use the Jetty 9 version that the starter app uses? (Is there a reason for upgrading to Jetty 10?)

Dustin Getz17:03:12

We are reorganizing this stuff this week for the next release, we might add CI/CD for the Jetty 10 version

Yab Mas17:03:47

Nah no reason to use 10, it just looked simpler and I interpreted the comments as if thats the preferred way but you go with 9 for java 8 compatibility. I'll give it a try after dinner!

Geoffrey Gaillard17:03:34

electric-ws-message-handler takes the ring request as first argument. You can try with

(defn wrap-websocket [next-handler ws-handler]
  (fn [request]
    (if (jetty/ws-upgrade-request? request)
      (jetty/ws-upgrade-response (adapter/electric-ws-adapter (partial adapter/electric-ws-message-handler request))
      (next-handler request))))

Dustin Getz17:03:50

i don't like this line:

ws-handler (adapter/electric-ws-adapter adapter/electric-ws-message-handler)

Dustin Getz17:03:13

I don't see a line like that in our example

Dustin Getz17:03:34

and i agree it doesn't typecheck

Yab Mas19:03:10

Adding the req with partial like geoffrey suggested worked!

👍 2
Yab Mas19:03:31

I honestely do think what i posted is what you have in the examples, you just dont have that exact line like that because I sent it as an arg. Anyway thanks for the fix!

👍 2
Michael W17:03:31

On the latest master after removing the shadow-cljs stuff as shown in the commits on the master branch, all my tap> calls are not being registered. If I tap from the nrepl it shows up both in the shadow-cljs web dashboard and in portal. If I tap from electric code I see nothing. Also on the newest version I am seeing these log entries that I did not before, I don't know if it's related or not, my app is functioning the same.

INFO  : Unserializable reference transfer: datascript.lru$cache$reify__51539 datascript.lru$cache$reify__51539@38da68e3
INFO  : Unserializable reference transfer: datascript.lru$cache$reify__51539 datascript.lru$cache$reify__51539@3971f8cf
INFO  : Unserializable reference transfer: clojure.lang.Atom clojure.lang.Atom@2e08353f
INFO  : Unserializable reference transfer: clojure.lang.Atom clojure.lang.Atom@2d13c329
INFO  : Unserializable reference transfer: datascript.db.Datom #datascript/Datom [1 :player/session-id "RVgyUGZsRGJ2UEN1dzRGTldRRHd0Zz09" 536870913 true]

2
Dustin Getz17:03:52

it looks like an e/server got dropped in a refactor

Dustin Getz18:03:30

look for places where you're calling into datascript from the client

Dustin Getz18:03:03

this would also explain the tap> malfunction, if it is called from the wrong site

Michael W18:03:07

So I just found the serializable issue, I was accessing datascript from the client side where it should have been server side, so the issues with the log entry are fixed. Still not getting taps though, in (e/client) or (e/server) code, taps just do not show up.

Michael W18:03:42

If I hit tap from a comment, loaded directly to the nrepl it works, but anything in electric code is just being swallowed.

Dustin Getz18:03:14

Does println work?

Michael W18:03:21

yeah from server and client println is working, I see it on the terminal for server and on the browser console for client

Dustin Getz18:03:51

alright, if you push your repo i'll take a look

Michael W18:03:54

It'll be a bit later tonight can only work on this outside work hours and my lunch hour is up.

👍 2
Michael W15:03:38

I'm not sure exactly what caused this but it just started working for me after a clean start. Been a few days since I closed the repl I guess.

👀 2
Dustin Getz15:03:13

i suspect an issue on portal side

Michael W15:03:31

I switched to using reveal, portal does not like the new electric seutp.

👀 2
Michael W15:03:03

It's just to see taps so whatever works is fine by me.

Michael W15:03:34

But the problem I was seeing with taps not showing up is gone. It was happening for the shadow web tap stream too.

Michael W15:03:47

Now shadow tap stream and reveal both see taps

👍 2
Adrian Smith22:03:39

I was trying this demo out earlier today: https://gist.github.com/dustingetz/d58a6134be310e05307ca0b586c30947 but wasn't sure what to make of the error:

Dustin Getz23:03:28

the gists aren’t maintained, there is a repo for the painter demo linked from the readme i believe

Dustin Getz23:03:40

maybe the error is a missing e/client?

Adrian Smith09:03:12

I think the gist is linked from the main readme - probably how I found it

Dustin Getz11:03:22

Cool! @U04P1F17B2N we will take a look at optimizing that (on my machine the pen lags). It should 100% be fast

👍 2
Dag12:03:15

Yeah I managed to fix the cursor performance using only client-side values. Tried doing the same with the “currently drawing path” but somehow it didn’t work