Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to Browser REPL fails with Fireplace #1

Closed
mharju opened this issue Aug 5, 2013 · 4 comments
Closed

Connecting to Browser REPL fails with Fireplace #1

mharju opened this issue Aug 5, 2013 · 4 comments

Comments

@mharju
Copy link

mharju commented Aug 5, 2013

The Browser REPL fails to evaluate any forms on Fireplace with VIM.

Leiningen 2.2.0 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 5 2012 11:32:03)
Fireplace latest available on GitHub

Using the current example project repeat the following steps to reproduce:

lein do cljsbuild once, repl
vim src/
(comment
  ; 1. Connect to the nREPL
  ; 2. eval
    (run)
    (def repl-env (reset! 
           cemerick.austin.repls/browser-repl-env 
          (cemerick.austin/repl-env)))
  ; 2. open the localhost:8080 page on the browser
  ; 3. eval
    (cemerick.austin.repls/cljs-repl repl-env)
  ; 4. eval
  (+ 2 2))

Outputs an error:

; "Error evaluating:" (try (clojure.core/eval (quote (do (+ 2 2)))) (catch Exception e (clojure.core/print (clojure.core/apply clojure.core/str (clojure.core/interleave (clojure.core/repeat "\b") (clojure.core/map clojure.core/str (.getStackTrace e))))) (throw e))) :as "try{cljs.core.eval.call(null,cljs.core.list(new cljs.core.Symbol(null,\"do\",\"do\",-1640528316,null),cljs.core.list(new cljs.core.Symbol(null,\"+\",\"+\",-1640531484,null),2,2)));\n}catch (e13604){if((e13604 instanceof cemerick.austin.bcrepl_sample.Exception))\n{var e_13605 = e13604;\ncljs.core.print.call(null,cljs.core.apply.call(null,cljs.core.str,cljs.core.interleave.call(null,cljs.core.repeat.call(null,\"\\b\"),cljs.core.map.call(null,cljs.core.str,e_13605.getStackTrace()))));\nthrow e_13605;\n} else\n{if(\"\\uFDD0:else\")\n{throw e13604;\n} else\n{}\n}\n}"
; #<TypeError: Expecting a function in instanceof check, but got TypeError: Cannot call method 'call' of undefined>
; TypeError: Expecting a function in instanceof check, but got TypeError: Cannot call method 'call' of undefined
;    at eval (eval at <anonymous> (http://localhost:8080/app.js:19440:129), <anonymous>:2:68)
;    at eval (eval at <anonymous> (http://localhost:8080/app.js:19440:129), <anonymous>:13:4)
;    at eval (eval at <anonymous> (http://localhost:8080/app.js:19440:129), <anonymous>:18:3)
;    at http://localhost:8080/app.js:19440:124
;    at clojure.browser.repl.evaluate_javascript (http://localhost:8080/app.js:19447:4)
;    at Object.callback (http://localhost:8080/app.js:19503:118)
;    at goog.messaging.AbstractChannel.deliver (http://localhost:8080/app.js:17853:34)
;    at goog.net.xpc.CrossPageChannel.xpcDeliver (http://localhost:8080/app.js:18736:307)
;    at Function.goog.net.xpc.NativeMessagingTransport.messageReceived_ (http://localhost:8080/app.js:18363:14)
;    at goog.events.Listener.handleEvent (http://localhost:8080/app.js:14021:51)
@mharju
Copy link
Author

mharju commented Aug 10, 2013

I finally had time to look what's wrong with this. As the error message suggests, Fireplace evals the forms it sends to nREPL by embedding them to

'(try (clojure.core/eval ''(do '.a:expr."\n".'))' .
        \ ' (catch Exception e' .
        \ '   (clojure.core/print (clojure.core/apply clojure.core/str (clojure.core/interleave (clojure.core/repeat "\b") (clojure.core/map clojure.core/str (.getStackTrace e)))))' .
        \ '   (throw e)))', ...

This can be circumvented by creating a new function to Fireplace that allows the user to send "raw evals". I tested this on my fork of Fireplace and it seems to fix this.

So therefore I think this issue can be closed and I will issue a pull request to Fireplace if I can make the fix decent enough.

@mharju mharju closed this as completed Aug 10, 2013
@cemerick
Copy link
Owner

Yup, makes sense. This is part of why I started work on a fork of Fireplace (maybe to be merged upstream, maybe not…there may be conflicting goals). Thanks for chasing this down.

@yayitswei
Copy link

@mharju Ran into this issue too, looking forward to your pull request.

@mharju
Copy link
Author

mharju commented Aug 19, 2013

@yayitswei I've still not been able to allocate more time for doing this. See discussion in tpope/vim-fireplace#83 to see where I'm at now. :)

cemerick pushed a commit that referenced this issue Nov 5, 2013
Catch up with upstream from cemerick/austin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants