aboutsummaryrefslogtreecommitdiffstats
path: root/l/src
diff options
context:
space:
mode:
authorTeddy Wing2021-02-21 23:01:51 +0100
committerTeddy Wing2021-02-21 23:01:51 +0100
commit2a46357cb58d740611fc3ed1f7d58b2a76bce602 (patch)
tree138d46d4e1ba5a4624ffe4eaa52c0e2ac122f2d0 /l/src
parent371c3813dc789fbb558791f23afea9a69e13a4a8 (diff)
downloadextreload-2a46357cb58d740611fc3ed1f7d58b2a76bce602.tar.bz2
When `chrome.tabs.reload()` errors, double decrement the wait group
We added an extra increment to the wait group in the `reload-tab` function because when the `chrome.tabs.reload()` message succeeds, we receive two response messages for a single one sent. When an error comes back from the message, however, only one message is received instead of two. We must thus decrement the wait group an extra time to account for the lack of a second response message. Here's what the message sequence looks like: #<WAIT-GROUP :counter 6> Sending: {"id":2,"sessionId":"C67B0BF214B28E1233277D01B897438E","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}} Response: (OBJ (id . 2) (result OBJ (result OBJ (type . object) (subtype . error) (className . TypeError) (description . TypeError: Cannot read property 'reload' of undefined at <anonymous>:1:13) (objectId . 1547982045888266898.197.11)) (exceptionDetails OBJ (exceptionId . 15) (text . Uncaught) (lineNumber . 0) (columnNumber . 12) (scriptId . 1569) (exception OBJ (type . object) (subtype . error) (className . TypeError) (description . TypeError: Cannot read property 'reload' of undefined at <anonymous>:1:13) (objectId . 1547982045888266898.197.12)))) (sessionId . C67B0BF214B28E1233277D01B897438E)) #<WAIT-GROUP :counter 7> Sending: {"id":2,"sessionId":"C67B0BF214B28E1233277D01B897438E","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}} Response: (OBJ (id . 2) (result OBJ (result OBJ (type . object) (subtype . error) (className . TypeError) (description . TypeError: Cannot read property 'reload' of undefined at <anonymous>:1:13) (objectId . 1547982045888266898.197.13)) (exceptionDetails OBJ (exceptionId . 16) (text . Uncaught) (lineNumber . 0) (columnNumber . 12) (scriptId . 1569) (exception OBJ (type . object) (subtype . error) (className . TypeError) (description . TypeError: Cannot read property 'reload' of undefined at <anonymous>:1:13) (objectId . 1547982045888266898.197.14)))) (sessionId . C67B0BF214B28E1233277D01B897438E)) #<WAIT-GROUP :counter 8> Sending: {"id":2,"sessionId":"C67B0BF214B28E1233277D01B897438E","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}} Response: (OBJ (id . 2) (result OBJ (result OBJ (type . undefined))) (sessionId . C67B0BF214B28E1233277D01B897438E)) #<WAIT-GROUP :counter 9>
Diffstat (limited to 'l/src')
-rw-r--r--l/src/main.lisp5
1 files changed, 5 insertions, 0 deletions
diff --git a/l/src/main.lisp b/l/src/main.lisp
index 81f05d6..f6b7d07 100644
--- a/l/src/main.lisp
+++ b/l/src/main.lisp
@@ -78,6 +78,11 @@
;; Failed to reload tab.
(when (jsown:keyp (json-obj-get response "result") "exceptionDetails")
+ ;; `reload-tab` adds an extra increment to the wait group. If the call
+ ;; fails, we only receive one message instead of two, so the wait group
+ ;; must be decremented to match.
+ (wait-group:done *wg*)
+
(reload-tab (json-obj-get response "sessionId")))
(wait-group:done *wg*)))