     (tear-down repl-env)))
 
 (defn repl-env* [options]
-  (JscEnv. (atom nil) (atom nil) (atom nil) options))
+  (JscEnv. (atom nil) (atom nil) (atom nil) (atom nil) options))
 
 (defn repl-env
   [& {:as options}]

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

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


(defn- set-up-socket
  [repl-env opts address port]
  (when-let [socket @(:socket repl-env)]
    (close-socket socket))
  (reset! (:socket repl-env)
    (socket address port))
  ;; Start dedicated thread to read messages from socket
  (start-reading-messages repl-env opts))

(defn reconnect [repl-env opts]
  ((print-fn opts) "Reconnecting ...")
  (let [bonjour-name @(:bonjour-name repl-env)
        endpoint (resolve-bonjour bonjour-name 15000)]
    (if endpoint
      (let [endpoint-address (.getHostAddress (:address endpoint))
            endpoint-port (:port endpoint)]
        (mount-webdav repl-env bonjour-name endpoint-address endpoint-port)
        (set-up-socket repl-env opts endpoint-address (dec endpoint-port)))
      ((print-fn opts) "Failed to reconnect."))))

(defn setup
  [repl-env opts]
