Push node.js REPL output through *out* and *err*
Description
Environment
None
Attachments
1
CLJS-1176.diff
28 Mar, 2015
Activity
David Nolen
May 23, 2015 at 7:32 PM
Daniel Skarda
May 23, 2015 at 7:03 PM
In 0.0-3291 there is still one call to isAlive left on src/main/clojure/cljs/repl/node.clj:92
Chas Emerick
April 8, 2015 at 2:03 PM
Patch attached to CLJS-1192. Sorry for the snafu! :-/
Chas Emerick
April 8, 2015 at 1:37 PM
Damn, no, looks like I was using the JDK 8 javadoc when I wrote the patch: http://docs.oracle.com/javase/8/docs/api/java/lang/Process.html#isAlive--
Looks like this would be an equivalent expression:
(try (.exitValue proc) false (catch IllegalThreadStateException _ true))
We'll see if David prefers a patch for this, or to paste it in himself…
Joel Wilsson
April 8, 2015 at 1:10 PM
This doesn't work for me, because java.lang.Process does not have an isAlive() method. Maybe you were thinking of java.lang.Thread isAlive()?
user=> (require '[cljs.repl :as repl])
nil
user=> (require '[cljs.repl.node :as node])
nil
user=> (def env (node/repl-env))
#'user/env
user=> (repl/repl env)
Exception in thread "Thread-8" Exception in thread "Thread-9" java.lang.IllegalArgumentException: No matching field found: isAlive for class java.lang.UNIXProcess
at clojure.lang.Reflector.getInstanceField(Reflector.java:271)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:315)
at cljs.repl.node$pipe.invoke(node.clj:85)
at cljs.repl.node$setup$fn__10733.invoke(node.clj:109)
...
The node.js REPL environment currently lets the child node process inherit the JVM's stdout/err. This is bad for nREPL, and for any other setup where one would like to rebind out and/or err in order to redirect content
print
ed by ClojureScript code. Turning off the inheritance and pumping output from the process to out and err should be straightforward.Related nREPL/piggieback issue: https://github.com/cemerick/piggieback/issues/41