babashka / nbb

Scripting in Clojure on Node.js using SCI
Eclipse Public License 1.0
863 stars 52 forks source link

nREPL server exits on evaluation error #306

Closed throwaway974 closed 1 year ago

throwaway974 commented 1 year ago

Evaluating valid forms like (+ 1 1) or nbb.core/*file* work as expected. However, evaluating an invalid form, such as foobar when foobar hasn't been defined, will result in the nREPL server immediately exiting, and the following output is displayed in the terminal.

% nbb nrepl-server
nREPL server started on port 60705 on host 127.0.0.1 - nrepl://127.0.0.1:60705

file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:326
...
Al [Error]: Could not resolve symbol: foobar
    at new Al (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:176:80)
    at $APP.xn.j (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:1250:319)
    at $APP.xn.h (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:1250:273)
    at bs (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:326:191)
    at nu (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:443:378)
    at Du (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:453:84)
    at Ku.j (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:1697:87)
    at Ku.h (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:1696:30)
    at $w (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:2198:499)
    at $APP.mx (file:///opt/local/lib/node_modules/nbb/lib/nbb_core.js:623:121)

Environment

I was able to produce this problem using

Emacs-specific steps My working directory is laid out as follows:

dir/
  scripts/
    test.cljs

Then nbb nrepl-server is executed within dir. I open test.cljs, which looks as follows.

(ns scripts.test)

Then I typeM-x cider-connect-cljs and connect to the nREPL server directly. I am able to evaluate forms, get autocomplete, etc. up until I attempt evaluating something invalid.

VS Code specific steps Open the dir folder, then open scripts/test.cljs. On the bottom of the VS Code window, click "REPL" then click "Start your project with a REPL and connect". You can still evaluate forms, get autocomplete, and so on. But evaluating an invalid form will cause the REPL to suddenly exist. You can verify this by looking at the bottom of the VS Code window changing.

borkdude commented 1 year ago

Releasing as 1.2.163 on CI