-
Notifications
You must be signed in to change notification settings - Fork 8
Complete pending server-initiated request promises on default executor #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
fe73a2c
85d1a8a
6add493
58139e1
6aaf086
3de5ded
cb24771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ | |
;; client. This cannot be `(-> (p/deferred) (p/catch))` because that returns | ||
;; a promise which, when cancelled, does nothing because there's no | ||
;; exception handler chained onto it. Instead, we must cancel the | ||
;; `(p/deffered)` promise itself. | ||
;; `(p/deferred)` promise itself. | ||
(p/catch p CancellationException | ||
(fn [_] | ||
(protocols.endpoint/send-notification server "$/cancelRequest" {:id id}))) | ||
|
@@ -351,9 +351,16 @@ | |
(if-let [{:keys [p started] :as req} (get pending-requests id)] | ||
(do | ||
(trace this trace/received-response req resp started now) | ||
(if error | ||
(p/reject! p (ex-info "Received error response" resp)) | ||
(p/resolve! p result))) | ||
;; Note that we are called from the server's pipeline, a core.async | ||
;; go-loop, and therefore must not block. Callbacks of the pending | ||
;; request's promise will be executed in the completing thread, | ||
;; which should not be our thread. This is very easy for users to | ||
;; miss, therefore we complete the promise on the default executor. | ||
(p/thread-call :default | ||
|
||
(fn [] | ||
(if error | ||
(p/reject! p (ex-info "Received error response" resp)) | ||
(p/resolve! p result))))) | ||
(trace this trace/received-unmatched-response resp now))) | ||
(catch Throwable e | ||
(log-error-receiving this e resp)))) | ||
|
Uh oh!
There was an error while loading. Please reload this page.