   (-load [repl-env provides url]
     (load-javascript repl-env provides url))
   (-tear-down [repl-env]
+    (reset! torn-down true)
     (tear-down repl-env)))
 
 (defn repl-env* [options]
-  (JscEnv. (atom nil) (atom nil) (atom nil) (atom nil) options))
+  (JscEnv. (atom nil) (atom nil) (atom nil) (atom nil) (atom nil) (atom nil) options))
 
 (defn repl-env
   [& {:as options}]

              (.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})
