lilactown / punk

A data REBL built for the web
Eclipse Public License 2.0
148 stars 5 forks source link

Limits of EDN as transport format #19

Open plexus opened 4 years ago

plexus commented 4 years ago

I was hoping to use punk to inspect shadow-cljs's compiler state

(defn compile-prepare-hook
  {:shadow.build/stage :compile-prepare}
  [build-state & args]
  (tap> [::compile-prepare build-state args])
  build-state)

This caused errors on the frontend like

#error {:message Unsupported escape character: \.., :data {:type :reader-exception, :ex-kind :reader-error}}

I also had to kill the tab shortly afterwards. I had a look with websocat what's going over the wire, and it seems like Punk sends messages in EDN. When printing non-clojure objects to EDN its not a given that the result is readable, for instance in my case there are bits like this

#object[com.google.javascript.jscomp.CompilerOptions 0x5cc90b6b "CompilerOptions{aggressiveFusion=false ...

Maybe Transit would be something to consider? It allows for default handlers both on the read and the write side, so the result can be readable regardless of what people throw at it. It could also be a good extension point for users to provide their own tagged readers/writers. Transit will also parse a lot faster on the frontend.

awb99 commented 4 years ago

I have similar problems with EDN tagged literals. It seems that the clojure reader does not convert tagged literals back to java objects, but rather keeps them as data literals, which does not work with nav, which needs the underlying object.