-
Notifications
You must be signed in to change notification settings - Fork 177
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
Fix inspector silently doing nothing if eval errored #573
Conversation
d8c217f
to
c0b9094
Compare
|
(cond (contains? response :value) | ||
(inspect-reply msg response) | ||
|
||
(contains? (:status response) :eval-error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess here you can explain the hack a bit, everything else looks good to me.
|
||
(defn- failure [{:keys [transport] :as msg} err err-kw] | ||
(transport/send transport (base-error-response msg err err-kw :done))) | ||
(defn- success [msg inspector] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can give this some more meaningful name now - e.g. inspector-response
.
Could you explain to me or is there perhaps a place to read about this: which kinds of ClojureScript setup CIDER supports? I kinda lost it by now. Is it just the on-JVM compiler, or does it also support those self-bootstrapped things like running on Node, shadow-cljs or whatever else there is? |
@alexander-yakushev ping :-) |
Yeah, sorry, couldn't find the time to investigate the cljs portion yet. |
c0b9094
to
810aad1
Compare
Codecov Report
@@ Coverage Diff @@
## master #573 +/- ##
==========================================
- Coverage 72.84% 72.83% -0.02%
==========================================
Files 36 36
Lines 2438 2433 -5
Branches 142 144 +2
==========================================
- Hits 1776 1772 -4
+ Misses 520 517 -3
- Partials 142 144 +2
Continue to review full report at Codecov.
|
810aad1
to
5c596e2
Compare
Good thing I checked with ClojureScript, this patch didn't work well there:) Now I fixed that and addressed your comments. |
The problem
If you inspect an expression that throws an exception (e.g.
(/ 1 0)
), the inspector silently discards the exception as if nothing has happened. This is annoying.Why?
Cider already has machinery for things like that, e.g. if macroexpansion throws an error, it will be displayed in a special cider middleware error buffer. That is implemented by macroexpansion middleware using
with-safe-transport
which, in the case of error, returns a message with status[:done :macroexpansion-error]
. On the Emacs side, Cider'scider-nrepl-send-sync-request
listens to:done
events, and if there's an error status after it the error buffer will be raised.Why doesn't it work for inspector? Because at some point (#164) the inspector has been changed from having its own middleware command to riding upon
eval
command.eval
command is asynchronous and can return many results; and if the exception is thrown, it will send the exception as separate message and finish up with:done
message. Andcider-nrepl-send-sync-request
ignores everything except:done
.What is this fix?
A hack to make
eval :inspect true
interceptor to short-circuit the failed eval with[:done :inspect-eval-error]
message. Also, some refactoring to make the inspector middleware more like other middlewares.Does it have to be like this?
I have no idea. I don't know if CLJS implementation will work after this, why it must use
eval
command, and what can be safely refactored. Need someone's help with CLJS side, this is too complicated for me.BTW, it might be a good idea to hold this until 0.19 release.