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

Exception when using Ctrl-D in interactive mode #77

Closed
weavejester opened this issue Nov 8, 2018 · 3 comments
Closed

Exception when using Ctrl-D in interactive mode #77

weavejester opened this issue Nov 8, 2018 · 3 comments
Labels
Bug Good First Issue Simple tasks that would be a good choice for newcomers

Comments

@weavejester
Copy link

Expected behavior

Entering Ctrl-D in an interactive nREPL session makes it immediately exit.

Actual behavior

Entering Ctrl-D throws an exception and hangs the process.

Steps to reproduce the problem

$ clj -Sdeps '{:deps {nrepl {:mvn/version "0.4.5"}}}' -m nrepl.cmdline --interactive
nREPL server started on port 54732 on host 0:0:0:0:0:0:0:0 - nrepl://0:0:0:0:0:0:0:0:54732
nREPL 0.4.5
Clojure 1.9.0
Java HotSpot(TM) 64-Bit Server VM 10.0.2+13
user=> ^D
Exception in thread "main" clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: EOF while reading
	at clojure.lang.LispReader.read(LispReader.java:304)
	at clojure.lang.LispReader.read(LispReader.java:206)
	at clojure.lang.LispReader.read(LispReader.java:200)
	at clojure.core$read.invokeStatic(core.clj:3758)
	at clojure.core$read.invokeStatic(core.clj:3733)
	at clojure.core$read.invokeStatic(core.clj:3733)
	at clojure.core$read.invokeStatic(core.clj:3733)
	at clojure.core$read.invoke(core.clj:3733)
	at nrepl.cmdline$run_repl.invokeStatic(cmdline.clj:42)
	at nrepl.cmdline$run_repl.invoke(cmdline.clj:24)
	at nrepl.cmdline$_main.invokeStatic(cmdline.clj:179)
	at nrepl.cmdline$_main.doInvoke(cmdline.clj:138)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.main$main_opt.invokeStatic(main.clj:317)
	at clojure.main$main_opt.invoke(main.clj:313)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: EOF while reading
	at clojure.lang.Util.runtimeException(Util.java:221)
	at clojure.lang.LispReader.read(LispReader.java:258)
	... 21 more
@bbatsov bbatsov added Bug Good First Issue Simple tasks that would be a good choice for newcomers labels Nov 8, 2018
@bbatsov
Copy link
Contributor

bbatsov commented Nov 8, 2018

Yeah, we should fix this.

@mallt
Copy link
Contributor

mallt commented Nov 8, 2018

Changing the cmdline message from

{:op "eval" :code (pr-str (read))}

to

{:op "eval"
 :code (-> (read *in* false (read-string "(System/exit 0)"))
            pr-str)}

seems to do the trick by using the eof-error? and eof-value arguments of the read function.

Would this be an acceptable fix?

@bbatsov
Copy link
Contributor

bbatsov commented Nov 8, 2018

That seems reasonable. Probably I'd move the read outside of the doseq. You can also check how reply is handing Control+d.

Might be a good idea to also add some special handling of (exit) (as reply does).

mallt added a commit to mallt/nREPL that referenced this issue Nov 9, 2018
@bbatsov bbatsov closed this as completed in 6f87d93 Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good First Issue Simple tasks that would be a good choice for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants