bitemyapp / revise

RethinkDB client for Clojure
146 stars 8 forks source link

Deliver exceptions that occur in the agent to the triggering promise instead of letting the agent choke #2

Closed bitemyapp closed 10 years ago

cesarbp commented 10 years ago

It could be a minor fix like:

(defn read-into-conn [conn-agent reader-signal]
  ;; (println "reader started")
  (while (not (and (= (when (realized? reader-signal) @reader-signal) :stop)
                   (:inputShutdown (bean (@conn-agent :socket)))))
    ;; (spit "out.log" "ran read-into-conn")
    (let [resp (fetch-response (@conn-agent :in))
           ;; Here
           result (try (inflate resp) (catch Exception e e))]
      (send-off conn-agent deliver-result result))))

Thoughts?

bitemyapp commented 10 years ago

The reads have to happen inside the agent send-off in order to play nicely with the concurrency semantics. The agent functions themselves need to have error handling anyway. Supposedly bja from IRC is going to be taking a look at this might pick it up - we'll see what he says.

My primary concern isn't even the "inflate", it's mostly to do with socket interaction (ie, fetch-response). I don't really expect RethinkDB to send us protobufs we can't deserialize.

cesarbp commented 10 years ago

Fixed in 538835edb89d6c2bd551c2d510e81ac46b9a7af1 Will reopen if agent keeps crashing somehow I guess.