Fork me on GitHub
#yada
<
2019-02-07
>
frozenlock00:02:31

Does yada use the modification date on static files to force browsers to reload? (say for my app.js)

đź‘Ť 5
danielcompton02:02:28

From memory yes

frozenlock14:02:37

@malcolmsparks Thoughts on transmitting metadata being breaking behavior?

borkdude19:02:19

I’m returning this in a yada response function:

(d/chain (http/get source-url)
             :body
             bs/to-string
             #(scraper/select1 % "title")
             scraper/text
             (fn [title]
               (if (not= "Login Page" title)
                 title
                 (throw (ex-info (str "Could not fetch Confluence page for id " id)
                                 {:status 400})))))
What this does is get the title from some remote page, if it’s “Login Page” I throw an error. I get the right error code in the browser. But after a few of such requests, it seems that the application hangs. Should I handle this in a different way?

borkdude19:02:27

For some reason I had to add this kind of error handling:

(defn realize-body
  [ex-data]
  (if-let [body (:body ex-data)]
    (assoc ex-data :body (slurp body))
    ex-data))

(d/catch clojure.lang.ExceptionInfo
            (fn [^java.lang.Exception ex]
              (let [d (ex-data ex)
                    d (realize-body d)]
                (throw (ex-info (.getMessage ex) d)))))
and then it works

borkdude19:02:21

One of these aleph gotchas I guess

dominicm20:02:58

Seems like yada could be more helpful with its handling of failed deferreds.

borkdude22:02:49

If you forget to realize the body of an aleph response in case of an exception, weird things happen