           env (ana/empty-env)
           core (io/resource "cljs/core.cljs")]
       ((println-fn opts) "\nConnecting to" (bonjour-name->display-name bonjour-name) "...\n")
+      (reset! (:reconnect-fn repl-env) (partial reconnect repl-env opts))
       (set-up-socket repl-env opts endpoint-address (dec endpoint-port))
       (when (= "true" (:value (jsc-eval repl-env "typeof cljs === 'undefined'")))
         ;; compile cljs.core & its dependencies, goog/base.js must be available

              (.append sb (char c))
              (recur sb (.read in))))))

(defn start-reading-messages
  "Starts a thread reading inbound messages."
  [repl-env opts]
  (.start
        (Thread.
          #(try
            (let [rv (read-messages (:in @(:socket repl-env)) (:response-promise repl-env) opts)]
              (when (= :eof rv)
                (close-socket @(:socket repl-env))))
            (catch IOException e
              (when-not (.isClosed (:socket @(:socket repl-env)))
                (.printStackTrace e)))))))

(defn stack-line->canonical-frame
  "Parses a stack line into a frame representation, returning nil

      (tear-down repl-env)
      (throw t))))

(defrecord JscEnv [response-promise bonjour-name webdav-mount-point socket torn-down reconnect-fn options]
  repl/IReplEnvOptions
  (-repl-options [this]
    {:require-foreign true})
