                (let [{:keys [error? ex source]} msg]
                  (cond
                    error?
-                   (do (send! {:tag :err :msg (str "Failed to read: " ex)})
+                   (do (send! {:tag :err :val (str "Failed to read: " ex)})
                        (recur loop-state))
 
                    (= ":repl/quit" source)


                 ::m/session-out
                 (do (when (= session-id (::m/session-id msg))
                       (send! {:tag :out :msg (::m/text msg)}))
                     (recur loop-state))

                 ::m/session-err
                 (do (when (= session-id (::m/session-id msg))
                       (send! {:tag :err :msg (::m/text msg)}))
                     (recur loop-state))

                 ::m/runtime-disconnect
                 (if-not (= runtime-id (::m/runtime-id msg))
                   (recur loop-state)
                   ;; inform client and let loop end, ending in disconnect
                   (send! {:tag :err :msg "The JS Runtime disconnected."}))

                 ;; mostly likely coming after disconnect on the browser reload
                 ;; FIXME: should disconnect not actually disconnect but rather just wait?

          (alt!!
            server-close
            ([_]
             (send! {:tag :err :val "The server is shutting down."})
             :close)

            ;; input from tool
