File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 95
95
; ; client. This cannot be `(-> (p/deferred) (p/catch))` because that returns
96
96
; ; a promise which, when cancelled, does nothing because there's no
97
97
; ; exception handler chained onto it. Instead, we must cancel the
98
- ; ; `(p/deffered )` promise itself.
98
+ ; ; `(p/deferred )` promise itself.
99
99
(p/catch p CancellationException
100
100
(fn [_]
101
101
(protocols.endpoint/send-notification server " $/cancelRequest" {:id id})))
351
351
(if-let [{:keys [p started] :as req} (get pending-requests id)]
352
352
(do
353
353
(trace this trace/received-response req resp started now)
354
- (if error
355
- (p/reject! p (ex-info " Received error response" resp))
356
- (p/resolve! p result)))
354
+ ; ; Note that we are called from the server's pipeline, a core.async
355
+ ; ; go-loop, and therefore must not block. Callbacks of the pending
356
+ ; ; request's promise will be executed in the completing thread,
357
+ ; ; which should not be our thread. This is very easy for users to
358
+ ; ; miss, therefore we complete the promise on the default executor.
359
+ (p/thread-call :default
360
+ (fn []
361
+ (if error
362
+ (p/reject! p (ex-info " Received error response" resp))
363
+ (p/resolve! p result)))))
357
364
(trace this trace/received-unmatched-response resp now)))
358
365
(catch Throwable e
359
366
(log-error-receiving this e resp))))
You can’t perform that action at this time.
0 commit comments