Skip to content

Cursive's nREPL middleware hides eval errors from other clients connected to the same server #3112

Open

Description

@solussd

When Cursive connects to an nREPL server, it adds cursive.repl.runtime.middleware/wrap-errors to the server's middleware stack (via add-middleware). From then on, eval errors are hidden from every client on that server, not just Cursive. No other client receives the error text (:err).

Environment

  • Cursive 2026.2-262, IntelliJ IDEA 2026.2.0.1, macOS 27.0 (26A5425a)
  • nREPL 1.3.1 (server started with nrepl.server/start-server, default handler), Clojure 1.11.1, Java 21.0.12

To reproduce

  1. Start an nREPL 1.3.1 server and connect Cursive to it as a remote REPL.
  2. From a different nREPL client on the same server (here clj-nrepl-eval from clojure-mcp-light), eval (/ 1 0).

Expected (what happens before Cursive connects, or after its middleware is removed): an :err message with Execution error (ArithmeticException) at …, then :ex/:root-ex with status eval-error.

Actual: no :err message. The response carries :ex, :root-ex, status eval-error, and a non-standard :exception key (a printed map of the error). Clients that show the :err text show nothing, so a failing eval looks like an eval that returned nothing.

Cause. wrap-errors runs inside nrepl.middleware.caught/wrap-caught. Its transport removes :nrepl.middleware.caught/throwable from the eval response and adds :exception, so when the response reaches wrap-caught's transport there is no throwable left, and wrap-caught never calls the caught function that writes the error to *err*. Because the middleware is installed for the whole server, this applies to responses for every session, not only Cursive's.

Suggested fix: add :exception without removing ::caught/throwable, so wrap-caught still prints the error for other clients. Cursive can ignore the resulting :err on its side.

Workaround: remove the middleware with nREPL's swap-middleware op (the stack from ls-middleware, minus wrap-errors). Cursive adds it back the next time it connects.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions