             (flush))
           :success
           (catch Throwable t
-            (notify-all-queues-of-error)
+            (notify-all-queues-of-error t)
             (when (System/getenv "DEBUG") (clojure.repl/pst t))
             :failure))]
     (when (= :success continue)


(def response-queues (atom {}))

(defn notify-all-queues-of-error []
  (doseq [session-key (keys @response-queues)]
    (.offer ^LinkedBlockingQueue (@response-queues session-key)
            {:status "error" :global true})))

(defn session-responses [session]
  (lazy-seq

  (let [relevant-message (or (= command-id (:id message)) (:global message))
        error (some #{"error" "eval-error"} (:status message))
        done (some #{"done" "interrupted"} (:status message))]
    (when error
      (when-let [caught (:caught options)]
        (execute-with-client client options (str "(" (pr-str caught) ")")))
      (when (:global message)
        (throw (:error message))))

    (and relevant-message (or error done))))

