Skip to content

Commit 8a52de9

Browse files
committed
oauth2-auto--request: retrieve URL synchronously
aio-url-retrieve sometimes hangs. Backported from kidd/org-gcal.el#200.
1 parent 085bb70 commit 8a52de9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

oauth2-auto.el

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,13 @@ Also send data in EXTRA-ALIST."
299299
(url-request-data data)
300300
(url-request-extra-headers
301301
'(("Content-Type" . "application/x-www-form-urlencoded")))
302-
;; TODO: using `aio-url-retrieve' sometimes results in a hung connection
303-
(response-buffer (cdr (aio-await (aio-url-retrieve url))))
302+
;; TODO: using `aio-url-retrieve' sometimes results in a hung
303+
;; connection, so we fall back to ‘url-retrieve-synchronously’ instead.
304+
;; This method shouldn’t be called very often, only when obtaining the
305+
;; initial access token and when refreshing tokens, which only happens
306+
;; every hour or so. Therefore I think this is an acceptable workaround
307+
;; for now.
308+
(response-buffer (aio-await (url-retrieve-synchronously url)))
304309
(response (with-current-buffer response-buffer
305310
(prog1 (oauth2-auto--request-access-parse)
306311
(kill-buffer (current-buffer))))))

0 commit comments

Comments
 (0)