Function: nrepl--dispatch-response
nrepl--dispatch-response is a byte-compiled function defined in
nrepl-client.el.
Signature
(nrepl--dispatch-response RESPONSE)
Documentation
Dispatch the RESPONSE to associated callback.
First we check the callbacks of pending requests. If no callback was found, we check the completed requests, since responses could be received even for older requests with "done" status.
When neither table has a callback for the response's id, log a message instead of raising an error: there is nothing actionable for the dispatcher to do, and signaling here used to abort processing of any later responses sitting in the queue.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/nrepl-client.el
(defun nrepl--dispatch-response (response)
"Dispatch the RESPONSE to associated callback.
First we check the callbacks of pending requests. If no callback was found,
we check the completed requests, since responses could be received even for
older requests with \"done\" status.
When neither table has a callback for the response's id, log a message
instead of raising an error: there is nothing actionable for the
dispatcher to do, and signaling here used to abort processing of any
later responses sitting in the queue."
(nrepl-dbind-response response (id)
(nrepl-log-message response 'response)
;; Surface a Clojure-only rejection for asynchronous ops. Synchronous
;; requests get a `user-error' from `nrepl-sync-request' so the calling
;; command aborts cleanly instead of reporting empty results.
(when-let* ((msg (nrepl--clojure-only-error response)))
(message "%s" msg))
(let ((callback (or (gethash id nrepl-pending-requests)
(gethash id nrepl-completed-requests))))
(cond
(callback (funcall callback response))
;; No handler: the request finished long ago and was evicted from
;; `nrepl-completed-requests', yet output keeps arriving (e.g. a
;; core.async go-loop still printing under the original eval's id).
;; Let a higher layer route the stray output rather than dropping it.
;; This must never abort the dispatcher (see the #853 history), hence
;; `with-demoted-errors'.
((and nrepl-orphaned-output-function
(with-demoted-errors "[nREPL] orphaned-response handler error: %S"
(funcall nrepl-orphaned-output-function response))))
(t (message "[nREPL] No response handler with id %s found for %s" id (buffer-name)))))))