Skip to content

Commit

Permalink
oauth2-auto--request: retrieve URL synchronously
Browse files Browse the repository at this point in the history
aio-url-retrieve sometimes hangs. Backported from
kidd/org-gcal.el#200.
  • Loading branch information
telotortium committed Nov 29, 2022
1 parent 085bb70 commit 8a52de9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions oauth2-auto.el
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,13 @@ Also send data in EXTRA-ALIST."
(url-request-data data)
(url-request-extra-headers
'(("Content-Type" . "application/x-www-form-urlencoded")))
;; TODO: using `aio-url-retrieve' sometimes results in a hung connection
(response-buffer (cdr (aio-await (aio-url-retrieve url))))
;; TODO: using `aio-url-retrieve' sometimes results in a hung
;; connection, so we fall back to ‘url-retrieve-synchronously’ instead.
;; This method shouldn’t be called very often, only when obtaining the
;; initial access token and when refreshing tokens, which only happens
;; every hour or so. Therefore I think this is an acceptable workaround
;; for now.
(response-buffer (aio-await (url-retrieve-synchronously url)))
(response (with-current-buffer response-buffer
(prog1 (oauth2-auto--request-access-parse)
(kill-buffer (current-buffer))))))
Expand Down

0 comments on commit 8a52de9

Please sign in to comment.