Skip to content

Commit 3a21a5e

Browse files
committed
Clarify cancellation and document dangerous blocking scenarios
1 parent d227abc commit 3a21a5e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/lsp4clj/server.clj

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@
9090
;; Chaining `(-> (p/deferred) (p/catch ...))` seems like it should work, but
9191
;; doesn't.
9292
(let [p (p/deferred)]
93+
;; side-effect of cancellation:
9394
(p/catch p CancellationException
94-
(fn [ex]
95-
(protocols.endpoint/send-notification server "$/cancelRequest" {:id id})
96-
(p/rejected ex)))
95+
(fn [_]
96+
(protocols.endpoint/send-notification server "$/cancelRequest" {:id id})))
9797
(map->PendingRequest {:p p
9898
:id id
9999
:method method
@@ -221,11 +221,9 @@
221221
;; If the server blocks waiting for a response, we have to set aside
222222
;; the other inbound requests and notifications, so that we can get to
223223
;; the response. That is, while the server is blocking we cannot stop
224-
;; reading input. Otherwise, the server will end up in a deadlock,
225-
;; where it's waiting to receive a response off the input-ch but new
226-
;; messages aren't being put on the input-ch because the server is
227-
;; blocked. See
228-
;; https://github.com/clojure-lsp/clojure-lsp/issues/1500.
224+
;; accepting input. Otherwise, the server will end up in a deadlock,
225+
;; where it's waiting to receive a response, but the response is
226+
;; waiting to be accepted.
229227

230228
;; To accomplish this we processes inbound requests and notifications
231229
;; separately from inbound responses. If the server starts blocking

0 commit comments

Comments
 (0)