clojure-emacs / clojure-emacs/cider

Improve ClojureScript error and compiler-warning rendering

Open
#4,043 0 comments 0 reactions 0 assignees View on GitHub
ClojureScript enhancement
Dominant language
Emacs Lisp
Stars
3.7k
Forks
651
Avg merge
11h 6m
Merged PRs (30d)
33

Description

When a ClojureScript evaluation fails or the compiler emits a warning, the experience is noticeably poorer than for Clojure: you get a plain message overlay and the raw error text, with no clickable jump to the offending source location and no cause/frame view.

### Why it's degraded today

Clojure errors flow through `analyze-last-stacktrace`, which analyzes a JVM `Throwable` and returns rich structured causes/frames that `cider-stacktrace` renders. ClojureScript errors are JavaScript errors with no JVM exception structure, so:

- cljs connections lack the `jvm-compilation-errors` capability, and `cider--display-error-unobtrusively` is used instead - it just concatenates the cause messages into an overlay (`cider-compilation.el` ~336-345);
- compiler warnings (`Use of undeclared Var ... at line N column M`) arrive as plain stderr text and aren't parsed, so there's no jump-to-location.

### Suggested approach (two phases)

**Phase 1 - client side (higher ROI).** Parse cljs compiler-warning/error text to extract file/line/column and turn it into a clickable source location + a better overlay, reusing the existing `cider-extract-error-info` / `cider--find-last-error-location` machinery (which currently only matches the JVM `at ns (file.clj:line:col)` shape). The wrinkle is that warning/error text **varies by backend** (piggieback vs shadow-cljs vs figwheel), so the parser has to be validated against real output rather than guessed.

**Phase 2 - middleware, optional/harder.** Teach cider-nrepl's stacktrace path to detect a cljs REPL and return structured location/cause data extracted from the piggieback/shadow JS error object, so cljs can get a richer view closer to Clojure's. There's already a `test/cljs/cider/nrepl/middleware/cljs_stacktrace_test.clj` to build on.

### Validating against live REPLs

This is the key reason it wasn't done blind: cider-nrepl has the infra to capture real formats - node + `cider/piggieback`, a `test/shadow-cljs` harness, and the existing cljs stacktrace test. Phase 1's parser should be pinned against actual node/piggieback and shadow-cljs warning output before shipping.

Comes out of the ClojureScript support review; see the cljs overview's Feature support section. Needs a companion change in cider-nrepl for Phase 2.

Contributor guide

Open the contributing guide

Research direction

Start with cider-compilation.el around lines 336-345 and the existing cider-extract-error-info and cider--find-last-error-location machinery. Capture warning and error formats from the node/piggieback and shadow-cljs harnesses, then inspect test/cljs/cider/nrepl/middleware/cljs_stacktrace_test.clj. Done means real formats are covered and source locations become clickable without regressing existing Clojure handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, node.js
Domain
developer-experience, testing, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.