Description
The changes introduced in #3616 to filter out stderr messages cause actual eval errors to be swallowed up when cider-show-error-buffer
is set to nil.
Expected behavior
Error messages should always be displayed to the user.
Actual behavior
In certain situations, there is no indication is given of the eval command having successfully completed/ failed, which may be misinterpreted as ongoing evaluation or a REPL crash.
Steps to reproduce the problem
Elisp:
(setq cider-show-error-buffer nil)
JVM clojure
cider-eval
the following and observe the lack of an error overlay (the only feedback being an error output in the possibly hidden REPL buffer)
(slurp "does-not-exist.txt")
Stderr output:
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
does-not-exist.txt (No such file or directory)
Babashka
Jack into a bb repl and trigger any exception, observe that all error overlays are suppressed.
(ns repro)
(inc nil)
Stderr output:
java.lang.NullPointerException repro /Users/yuhan/.local/scripts/repro.bb:2:1
Additional context
The issue can be traced to this conditional
Line 925 in a74dff9
which only displays the error overlay if the stderr output matches an expected clojure-1.10 regexp, notice that the exception thrown from
slurp
doesn't match due to the 'line number' being negative:
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
does-not-exist.txt (No such file or directory)
One straightforward fix would be to tweak the cider-clojure-1.10--location
regexp to accept the -
char
Line 571 in a74dff9
But this seems to be an especially brittle way of doing things - are we sure that the regex fully describes all valid error messages? I had no idea that interop calls could result in negative line numbers, maybe it's due to the absence of .java sources or specific to the JDK that I'm running, and I'm certain there are more edge cases that aren't covered by this regex.
Not to mention that it breaks compatibility with Clojure < 1.9 in an unnecessarily severe manner - A false negative here can be quite confusing since it manifests as zero feedback of any kind, which seems as though the REPL has crashed or is still busy processing.
I think that a more robust approach would be to default to showing all errors, and leaving it to a user-defined regex to weed out any false positives. This way the original issue with Timbre logs would be solved by something like
;; Filter anything that begins with an ISO date stamp
(setq cider-suppressed-error-regexp "^[[:digit:]]\\{4\\}-")
Environment & Version information
CIDER version information
;; CIDER 1.14.0-snapshot (package: 1.14.0-snapshot), nREPL 1.2.0-beta1
;; Clojure 1.12.0-alpha9, Java 21.0.2
Lein / Clojure CLI version
Clojure CLI version 1.11.3.1463
Emacs version
29.3
Operating system
NA
JDK distribution
openjdk version "21.0.2" 2024-01-16 LTS