-
Notifications
You must be signed in to change notification settings - Fork 178
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
compliment can cause cider-nrepl to err out #313
Comments
Seems to me the bug is in compliment, but I also see you've already reported it there. |
Yes, but we should wrap our call to compliment in a |
As I mentioned in the other ticket - ideally compliment should raise some more specific exceptions which we would handle. As it stands this is way too generic. |
@bbatsov We should fail gracefully imo. Making CIDER completely unusable just because there's a problem with completions seems extreme. As it is now you can't type when something goes wrong because the focus is changed, from whatever window you're typing in, to the repl on each keystroke. Can we at least make it so the repl is spammed without changing focus? |
@expez I was able to replicate the behavior, but I had a very difficult time doing so naturally -- I only finally saw the stack traces when I patched the compliment code itself to throw a null pointer exception. I'm not exactly sure how the nil got into that function since the elisp code always sends a non-nil namespace over (as far as I can see). Would you be able to give me a list of the namespaces you typically use? Perhaps a In the meantime, I'm getting a PR ready that would swallow these types of errors in the completion middleware, returning an empty completion and sending back some error information. |
oh, and also @expez , could you give me the full string that you get when you do an |
@sanjayl There's no debugging required here, I think. A bug was fixed in compliment and we just need to wrap the call to compliment in a I think we're waiting for @alexander-yakushev to wrap his own code in a Fwiw I don't have any unicode namespaces, it's all ASCII. |
Difficult to reproduce error with a Null Pointer Exception deep within the Compliment code. Not clear how the `nil` made it there? This commit will swallow exceptions from the complete-op (not the eldoc-op) and just act like there were no matches found. Eventually would like more notification for the user so that we can squash as many bugs as possible.
@expez , while we're waiting for the relevant patches, I put up a branch on my repo that should swallow the errors you're seeing and prevent any interruption in your workflow until things are ironed out a bit better. You can do a local install with I do still think that there's a need to debug this further. I'm having a tough time wrapping my head around how that Thanks! |
I don't mind adding a few try-catches, but I really don't understand the logic behind rethrowing exceptions in this case. It's a very Javaesque practice. Why would |
@alexander-yakushev , agreed. I think figuring out how this error is happening will have the most utility. For anyone interested in similar types of issues in CIDER, I think it's important to note that the CIDER code already has a
Having a stacktrace show up in the REPL is clearly not the optimal or most user friendly solution, but it is more user friendly than the behavior of having the exception go uncaught -- which completely hangs the system and requires a C-c C-b to interrupt the hung evaluation thread! I'm still trying to grab all the low hanging fruit WRT error handling (i.e., prevent hangs due to exceptions), but I do intend to try and improve the user experience and find a happy medium between silently swallowing an exception and getting a stacktrace thrown in your face. I'm about half way done with the easy stuff, so stay tuned... |
In that case, the correct solution would be to catch and rethrow the exception here: https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/complete.clj#L19 By arbitrary rethrowing errors inside Compliment I would force hypothetical developers that might want to wrap Compliment in their own libraries (not in the user-facing solution that CIDER is) to manually unpack my rethrown exception, or to read a folded stacktrace. |
I just had this happen to me again. This time it happened because the completion was triggered in file which hadn't been loaded yet:
Obviously |
I am running into this quite often, usually after doing a Is there any way to work around this for now? It makes working with CIDER pretty much impossible. |
@jstaffans: if you clone the cider-nrepl repo, make the single change shown with the |
What's the exact exception your getting? As I said before I'm against just ignoring all exceptions as this would masquerade real issues with the code. I'm still open to idea regarding this, but as I said before - it's not wise to suppress generic exceptions that might occur for 10 different reasons. If there was something more specific we could handle - it would certainly help. |
I get the exact same stack trace as mentioned in the original bug report for this issue. @sanjayl I'll try that out when I have more time, for now I switched editors. |
@bbatsov There is |
So, I've updated compliment - let me know if this fixes the bug or not. |
Thanks, I'll keep you posted. |
I still get the same stacktrace and REPL focus using |
@jstaffans Dependes whether cider-nrepl snapshot was re-downloaded or not. Regardless, it seems that you have a quite reproducible case. It will be extremely helpful if you write down the exact steps that lead to the said stacktrace printed. Thank you! |
@alexander-yakushev : Maybe there needs to be a check in |
@sanjayl It could be so, but when |
You're right. If only someone could reproduce this reliably... |
On a related note, we should probably add an option to suppress internal middleware errors, so their presence won't be so disruptive to users in the absence of a proper solution. |
Why don't we redirect them to |
We're about to remove this functionality completely in this release - @sanjayl is working on a solution that would allow us to display regular stacktrace buffers in case of such errors (as opposed to dumping some stacktrace in the REPL). We should just add an option not to display/select them automatically IMO. |
I think stacktrace buffers are OK for errors that happen once in a blue moon, but when there's a bug, like the one which caused me to open this issue, the stacktrace buffer isn't an improvement. What I'd like:
|
We'll implement something like 1 for sure. As for 2 - I like the idea, but I'm not sure we'll find someone to work on something like this any time soon. |
Once CIDER PR #1645 lands (which sends all exceptions to a stacktrace buffer instead of spamming the REPL), I think option 1 will work out of the box. There's a variable named Customizing this behavior further as required by option 2 or something similar is possible but will require slightly broadening the scope of some of the internal plumbing. I need to dig a bit deeper into the code to see how that can be done best. |
Still, you'd want to treat internal errors differently from eval errors, so it's not as simple as this. But you're right - at least people will be able to workaround the problem. |
Here's a quick screencast of what I have so far, I think it satisfies both No. 1 and 2 from above: |
Excellent. I have a few remarks about the UI, but I'll mention them on the Elisp PR when you file it. |
Guess we can close this. |
Expected behavior
Errors in
compliment
only result in missing completionsActual behavior
Input is interrupted and repl is filled with stacktracke:
Steps to reproduce the problem
Not sure. Should be trivial to solve with code inspection.
Environment & Version information
cider-nrepl version
Latest snapshot
Java version
1.8
Operating system
OSX, El capitan
The text was updated successfully, but these errors were encountered: