This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-20
Channels
- # aleph (12)
- # announcements (7)
- # aws (6)
- # babashka (36)
- # beginners (161)
- # boot (1)
- # calva (6)
- # cider (21)
- # clj-kondo (13)
- # cljs-dev (28)
- # cljsrn (1)
- # clojars (3)
- # clojure (13)
- # clojure-colombia (1)
- # clojure-europe (10)
- # clojure-spec (12)
- # clojure-uk (47)
- # clojuredesign-podcast (2)
- # clojurescript (67)
- # datascript (8)
- # datomic (21)
- # duct (3)
- # emacs (6)
- # events (1)
- # fulcro (6)
- # graalvm (98)
- # jobs (1)
- # kaocha (18)
- # luminus (1)
- # malli (7)
- # off-topic (56)
- # pathom (5)
- # re-frame (18)
- # reagent (3)
- # reitit (9)
- # remote-jobs (3)
- # rewrite-clj (10)
- # ring (1)
- # shadow-cljs (155)
- # spacemacs (2)
- # sql (5)
- # tools-deps (27)
- # vim (86)
- # xtdb (2)
I'm seeing this kind of error after pathom Index Explorer is trying to serialize the entire context and push it across the wire.
java.lang.Exception: Not supported: class com.wsscode.pathom.connect$fn__54398
java.lang.RuntimeException: java.lang.Exception: Not supported: class com.wsscode.pathom.connect$fn__54398
clojure.lang.ExceptionInfo: Malformed application/transit+json in :muuntaja/encode
format: "application/transit+json"
type: :muuntaja/encode
What is the best way to configure muuntaja to simply ignore things it can't encode correctly in application/transit+json
?
You are returning a function, which can't be serialized. I don't think disabling encoding helps here. I would double-check how to serialize the context.
Just trying to think this through, I've tried e.g.:
(def generic-function-writer
(transit/write-handler
(constantly "fn")
(fn [v] (pr-str v))
(fn [v] (pr-str v))))
(def muuntaja-instance
(muuntaja/create
(-> muuntaja/default-options
(assoc-in
[:formats "application/transit+json" :encode-opts]
{:handlers {java.util.function.Function generic-function-writer}}))))
... but, will most likely to blow up in the web server. Maybe you should invoke the function yourself?
To clarify, I'm using reitit-http
and my router has {:data {:muuntaja my-muuntaja-instance}}
.
I expect, that the (interceptor.muuntaja/format-response-interceptor)
should pick up this custom muuntaja instance?
This is a weird setup - I didn't expect to get hit with a serialization problem like this. But it looks like a real thing, and the expected workaround for now: https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/connect/exploration.html#_fixing_transit_encoding_issues
I've done as you suggested for now @U055NJ5CC - just invoking the custom transit writer myself for this specific route. I'd still like to circle back to this later and figure out a nicer solution. Thanks!