-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
CIDER 1.1.1 Can't Handle Errors Without Stack Traces #3022
Comments
I'm not sure what's the best behaviour in such scenarios, as some stack frames seem to be missing. I recall this problem has been around for ages, but we never decided on the best approach to tackle it. E.g.:
|
Personally speaking I think adding that option by default seems like a great addition. I can't think of any interactive development situation where I wouldn't want it on, but maybe I'm not thinking of something common? |
I don't know nearly enough about the stack trace processing code but is it possible to somehow handle this case in the code that's emitting the
messages? While I think that it makes sense to add the JVM option by default it's actually those messages that make it feel like a bug in CIDER to me. If I just got a stack trace without a trace but CIDER wasn't raising errors I think that might be slightly better? |
Expands `cider-clojure-cli-jack-in-dependencies` to also add `:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]` in the `:cider/nrepl` alias so that there are less situations where CIDER encounters a stack trace that has no traceback. May be worth extending to the other `cider-*-jack-in-dependencies` functions. Fixes clojure-emacs#3022
Also I guess I should've linked the discussion in #cider :) https://clojurians.slack.com/archives/C0617A8PQ/p1624726767180000 Alex Miller even says that he's personally fixed this issue in Clojure several times. |
Edit: ignore this post!
diff --git a/cider-stacktrace.el b/cider-stacktrace.el
index 73bf2636..012c14a6 100644
--- a/cider-stacktrace.el
+++ b/cider-stacktrace.el
@@ -796,15 +796,14 @@ cider-stacktrace-render-cause
(with-current-buffer buffer
(nrepl-dbind-response cause (class message data spec stacktrace)
(let ((indent " ")
- (class-face 'cider-stacktrace-error-class-face)
- (message-face 'cider-stacktrace-error-message-face))
+ (message-face 'cider-stacktrace-error-message-face)
+ (level-0-message (concat (propertize note 'font-lock-face 'font-lock-comment-face) " "
+ (propertize class 'font-lock-face 'cider-stacktrace-error-class-face))))
+ ;; (message (propertize level-0-message 'face 'cider-test-failure-face))
(cider-propertize-region `(cause ,num)
;; Detail level 0: exception class
(cider-propertize-region '(detail 0)
- (insert (format "%d. " num)
- (propertize note 'font-lock-face 'font-lock-comment-face) " "
- (propertize class 'font-lock-face class-face)
- "\n"))
+ (insert (format "%d. " num) level-0-message "\n"))
;; Detail level 1: message + ex-data
(cider-propertize-region '(detail 1)
(if (equal class "clojure.lang.Compiler$CompilerException")
@@ -852,7 +851,8 @@ cider-stacktrace-initialize
(goto-char (next-single-property-change (point) 'compile-error))
(progn
(while (cider-stacktrace-next-cause))
- (goto-char (next-single-property-change (point) 'flags)))))))))
+ (goto-char (next-single-property-change (point) 'flags nil (point-max))))))))))
+
(defun cider-stacktrace-render (buffer causes &optional error-types)
"Emit into BUFFER useful stacktrace information for the CAUSES. |
@yuhan0 Which part of the code was the problematic one? Was that the modified |
I just got around to looking at this - turns out that change was for something else entirely! Sorry for any confusion 😓 The issue is in I agree with the discussion in #3023 that we should just check for this and point users to the relevant troubleshooting page, instead of setting any JVM option by default. Here's what it might look like: If that's ok I'll submit a PR :) But first the website should be updated to reflect the commit linked above 2f9bec5 |
A PR SGTM (FWIW!) I'd make sure to have at least one CI job run without the sensitive flag (i.e. probably duplicating the entire matrix would be overkill) |
@yuhan0 I've updated the docs site, so you can go ahead with the PR.
With the proposed solution I don't think we need any changes to the CI setup. We can just have add some unit test that mocks the nil stack frame, although I'm not sure there are any stacktrace related tests on the Elisp side. I'll take a simple PR without tests gladly, given the circumstances. |
My thinking is that creating a test for the By running a whole CI job with an alt flag set up, we implicitly exercise a lot of code for that flag value. |
My point was mostly that there are almost no integration tests in CIDER that check something against a real nREPL server. The tests typically stub the nREPL replies. That's why I didn't see why we'd run the tests with/without this JVM flag. |
This is what OSS is all about. I submit an issue and offer to do the work and then someone else beats me to it and makes my life better. Thanks everyone! :-D |
I just realised now that we're not in the cider-nrepl repo 🤦♂️ sorry for the noise. |
I wonder though how things are handled cider-nrepl side. There might be gains to be made especially for clients other than cider.el. |
Expected behavior
Be able to eval
(< 1 nil)
and get a reasonable stack trace.Actual behavior
CIDER panics with
*Messages*
and a Stacktrace buffer like
Steps to reproduce the problem
-XX:-OmitStackTraceInFastThrow
passed.(< 1 nil)
M-x cider-eval-last-sexp RET
This can be fixed by passing
-XX:-OmitStackTraceInFastThrow
to the underlying JVM via the appropriate channel.For instance:
Followed by
M-0 M-x cider-jack-in RET
and appending:dev
to the CL likeEnvironment & Version information
CIDER version information
clojure
versionEmacs version
Operating system
The text was updated successfully, but these errors were encountered: