Skip to content

Commit

Permalink
[new] [#447] [Community adapters] Improve error message on Ajax read …
Browse files Browse the repository at this point in the history
…timeouts

There may well be a better way of handling Ajax timeouts, but I'm unfortunately
not familiar with the involved servers.

PR or suggestions very welcome!
  • Loading branch information
ptaoussanis committed Dec 31, 2024
1 parent a169f45 commit 2540494
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/taoensso/sente/server_adapters/community/jetty.clj
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@

ISenteJettyAjaxChannel
(ajax-read! [_sch]
(let [{:keys [ajax-resp-timeout-ms]} adapter-opts]
(if ajax-resp-timeout-ms
(deref resp-promise_ ajax-resp-timeout-ms nil)
(deref resp-promise_)))))
(let [{:keys [ajax-resp-timeout-ms]} adapter-opts
result
(if ajax-resp-timeout-ms
(deref resp-promise_ ajax-resp-timeout-ms ::timeout)
(deref resp-promise_))]

(if (= result ::timeout)
(throw (ex-info "Ajax read timeout" {:timeout-msecs ajax-resp-timeout-ms}))
result))))

(defn- ajax-ch
[{:keys [on-open on-close]} adapter-opts]
Expand Down
13 changes: 9 additions & 4 deletions src/taoensso/sente/server_adapters/community/undertow.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@

ISenteUndertowAjaxChannel
(ajax-read! [sch]
(let [{:keys [ajax-resp-timeout-ms]} adapter-opts]
(if ajax-resp-timeout-ms
(deref resp-promise_ ajax-resp-timeout-ms nil)
(deref resp-promise_)))))
(let [{:keys [ajax-resp-timeout-ms]} adapter-opts
result
(if ajax-resp-timeout-ms
(deref resp-promise_ ajax-resp-timeout-ms ::timeout)
(deref resp-promise_))]

(if (= result ::timeout)
(throw (ex-info "Ajax read timeout" {:timeout-msecs ajax-resp-timeout-ms}))
result))))

(defn- ajax-ch [{:keys [on-open on-close]} adapter-opts]
(let [open?_ (atom true)
Expand Down

0 comments on commit 2540494

Please sign in to comment.