Fork me on GitHub
#datomic
<
2022-10-18
>
Benjamin11:10:02

Jo I'm implementing a :http-direct function using ring and there is an issue where ring.middleware.cookies returns a lazy seq (the "Set-Cookie" header value is a seq), but cognitect.http_endpoint.jetty expects a string - class clojure.lang.LazySeq cannot be cast to class java.lang.String

["cognitect.http_endpoint.jetty$respond_bbuf_STAR_",
      "invokeStatic", "jetty.clj", 342]}],
do you have advice on how to fix? I can of course coerce the seq into a string before returning in my handler

Benjamin11:10:52

(defn- set-cookies
  "Add a Set-Cookie header to a response if there is a :cookies key."
  [response encoder]
  (if-let [cookies (:cookies response)]
    (update-in response
               [:headers "Set-Cookie"]
               concat
               (doall (write-cookies cookies encoder)))
    response))

Benjamin11:10:39

I wonder if the author of cookies.clj wanted to say "apply str" instead of "concat"

pieterbreed12:10:06

This is an issue that is ion specific; you'll find that library works well enough in all the other ring servers. I just looked up our middleware for cookies on ion: Here is ours:

(defn wrap-http-direct [handler]
  (fn [req]
    (let [resp (handler req)]
      (if (contains? (:headers resp) "Set-Cookie")
        (update-in resp [:headers "Set-Cookie"] (fn [c]
                                                  (cond
                                                    (string? c) c
                                                    (seq c) (str/join "," c)
                                                    :else nil)))
        resp))))
I think this library can give you the same thing (but packaged as a lib...)
;; [net.icbink.expand-headers.core :as ion-cookies]
;; from net.icbink/expand_headers {:git/url ""
;;                                 :sha     "b2b0364422d71b8f233148942618b7b16da38ecf"}

Benjamin12:10:27

yea thanks I will copy this.

Henrik Suzuki14:10:03

Hi! Has anyone here any experience of not being able to connect to Datomic again after querying after too much data?

jaret15:10:40

On-prem? Cloud? What error do you get? Your transactor still running? Did the peer OOM?

kipz16:10:40

Hello. I'm trying to use with (as per https://docs.datomic.com/client-api/datomic.client.api.async.html#var-with) with :db/retractEntity, and the call never returns - just times out. Is this supposed to work? It does seem to work when I add attributes, so am just wondering if this is just not possible, or something else is going on here. Thanks in advance.

kipz11:10:15

FWIW - it does work mostly now. We think we have a dodgy query node 😬 Sorry for the noise.

Drew Verlee18:10:41

How do i use an aws role that has all the permissions to ensure an on-prem datomic transactor? https://forum.datomic.com/t/how-to-pass-ensure-transactor-fn-an-aws-role/2142.