Ok so I made a terrible hack to call figwheel from the browser to create a self-hosted REPL, and there's a ~10seconds delay after the first request, feels like a timeout from doing things the wrong way
if anyone's interested, fixed it by running the body of on-repl in a background thread, using an agent and send-off
Using this from cljs, where form is a string from CodeMirror:
(defn send [form ns]
(frepl/respond-to-connection {:op "demo/repl" :form form :ns ns}))And this monstrosity from clj:
(defn on-repl [{:keys [response]}]
(when (= "demo/repl" (:op response))
(binding [cljs.env/*compiler* (-> @figwheel.main.watching/*watcher* :watches
first second :figwheel.main/watch-info :compiler-env)]
(let [forms (cljs.analyzer.api/forms-seq (StringReader. (:form response)))
f1 (first forms)
mod (when (and (list? f1) (= 'ns (first f1)))
(second f1))
forms (conj (if-not mod forms (next forms)) 'do)
mod (or mod (symbol (or (:ns response) "cljs.user")))]
(cljs.repl/evaluate-form
(fapi/repl-env "dev")
(assoc (cljs.analyzer/empty-env) :ns (cljs.analyzer/get-namespace mod))
"<self repl>"
forms
(#'cljs.repl/wrap-fn forms))))))It works, surprisingly enough, but client requests are pending as if waiting on a timeout when fired within 10secs of each other
I think the server expects the flow to go from cider-like client -> server -> browser client, but here it's browser client -> server -> browser client