diff options
author | Teddy Wing | 2021-02-21 18:46:08 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-21 18:46:08 +0100 |
commit | 9eee64d10810ec28940c628bf0f8d7bd71cd456c (patch) | |
tree | 3149ee5a65bba224f40549dda6f21cc37c46404a /l/src | |
parent | b5af25ff7851498af855fe7f252117b3a0bee070 (diff) | |
download | extreload-9eee64d10810ec28940c628bf0f8d7bd71cd456c.tar.bz2 |
reload-tab: Fix inconsistent tab reloading
Finally managed to figure out why tab reloading was inconsistent. With
my added logs, I learned that _two_ responses come back from the
`chrome.tabs.reload()` message we send instead of one. This means that
the wait group gets decremented prematurely, and the program could exit
before we've transmitted the message(s).
To fix this, increment the wait group an extra time when sending the tab
reload message to account for the second message response.
Here are the logs:
One tab reloaded, one not:
#<WAIT-GROUP :counter 1>
Sending: {"id":2,"method":"Target.attachToTarget","params":{"targetId":"E1DA65BA7761486BBA9B341E5403744F","flatten":true}}
Sending: {"id":3,"method":"Target.attachToTarget","params":{"targetId":"84AFD21582910FC66AD0FB24E410BBC1","flatten":true}}
Response: (OBJ (method . Target.attachedToTarget)
(params OBJ (sessionId . C2BBFC26103DAB67ECC199C87CB38B86)
(targetInfo OBJ (targetId . E1DA65BA7761486BBA9B341E5403744F)
(type . background_page)
(title . TITLE)
(url
. chrome-extension://EXTENSION_ID/_generated_background_page.html)
(attached . T) (canAccessOpener)
(browserContextId . 29837CF1E6AC13B4FDA7DD2883E6320E))
(waitingForDebugger)))
#<WAIT-GROUP :counter 2>
Sending: {"id":1,"sessionId":"C2BBFC26103DAB67ECC199C87CB38B86","method":"Runtime.evaluate","params":{"expression":"chrome.runtime.reload()"}}
Response: (OBJ (id . 2)
(result OBJ (sessionId . C2BBFC26103DAB67ECC199C87CB38B86)))
#<WAIT-GROUP :counter 2>
Sending: {"id":2,"sessionId":"C2BBFC26103DAB67ECC199C87CB38B86","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}}
Response: (OBJ (method . Target.attachedToTarget)
(params OBJ (sessionId . 9ED44EDF0DA25CE52F21AA90EBAEF7D7)
(targetInfo OBJ (targetId . 84AFD21582910FC66AD0FB24E410BBC1)
(type . background_page)
(title . TITLE)
(url
. chrome-extension://EXTENSION_ID/_generated_background_page.html)
(attached . T) (canAccessOpener)
(browserContextId . E3DEC22E4F9847AAA674ACF4781D51A9))
(waitingForDebugger)))
#<WAIT-GROUP :counter 2>
Sending: {"id":3,"sessionId":"9ED44EDF0DA25CE52F21AA90EBAEF7D7","method":"Runtime.evaluate","params":{"expression":"chrome.runtime.reload()"}}
Response: (OBJ (id . 3)
(result OBJ (sessionId . 9ED44EDF0DA25CE52F21AA90EBAEF7D7)))
#<WAIT-GROUP :counter 2>
Sending: {"id":4,"sessionId":"9ED44EDF0DA25CE52F21AA90EBAEF7D7","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}}
Response: (OBJ (id . 1) (result OBJ (result OBJ (type . undefined)))
(sessionId . C2BBFC26103DAB67ECC199C87CB38B86))
#<WAIT-GROUP :counter 2>
Response: (OBJ (id . 3) (result OBJ (result OBJ (type . undefined)))
(sessionId . 9ED44EDF0DA25CE52F21AA90EBAEF7D7))
#<WAIT-GROUP :counter 1>
Both tabs reloaded:
#<WAIT-GROUP :counter 1>
Sending: {"id":2,"method":"Target.attachToTarget","params":{"targetId":"84AFD21582910FC66AD0FB24E410BBC1","flatten":true}}
Sending: {"id":3,"method":"Target.attachToTarget","params":{"targetId":"E1DA65BA7761486BBA9B341E5403744F","flatten":true}}
Response: (OBJ (method . Target.attachedToTarget)
(params OBJ (sessionId . A1BD02811FD42011A5325723F2D31819)
(targetInfo OBJ (targetId . 84AFD21582910FC66AD0FB24E410BBC1)
(type . background_page)
(title . TITLE)
(url
. chrome-extension://EXTENSION_ID/_generated_background_page.html)
(attached . T) (canAccessOpener)
(browserContextId . E3DEC22E4F9847AAA674ACF4781D51A9))
(waitingForDebugger)))
#<WAIT-GROUP :counter 2>
Sending: {"id":1,"sessionId":"A1BD02811FD42011A5325723F2D31819","method":"Runtime.evaluate","params":{"expression":"chrome.runtime.reload()"}}
Response: (OBJ (id . 2)
(result OBJ (sessionId . A1BD02811FD42011A5325723F2D31819)))
#<WAIT-GROUP :counter 2>
Sending: {"id":2,"sessionId":"A1BD02811FD42011A5325723F2D31819","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}}
Response: (OBJ (method . Target.attachedToTarget)
(params OBJ (sessionId . 4DC48E49A8133A13BED664D9C466F892)
(targetInfo OBJ (targetId . E1DA65BA7761486BBA9B341E5403744F)
(type . background_page)
(title . TITLE)
(url
. chrome-extension://EXTENSION_ID/_generated_background_page.html)
(attached . T) (canAccessOpener)
(browserContextId . 29837CF1E6AC13B4FDA7DD2883E6320E))
(waitingForDebugger)))
#<WAIT-GROUP :counter 2>
Sending: {"id":3,"sessionId":"4DC48E49A8133A13BED664D9C466F892","method":"Runtime.evaluate","params":{"expression":"chrome.runtime.reload()"}}
Response: (OBJ (id . 3)
(result OBJ (sessionId . 4DC48E49A8133A13BED664D9C466F892)))
#<WAIT-GROUP :counter 2>
Sending: {"id":4,"sessionId":"4DC48E49A8133A13BED664D9C466F892","method":"Runtime.evaluate","params":{"expression":"chrome.tabs.reload()"}}
Response: (OBJ (id . 1) (result OBJ (result OBJ (type . undefined)))
(sessionId . A1BD02811FD42011A5325723F2D31819))
#<WAIT-GROUP :counter 2>
Response: (OBJ (id . 2) (result OBJ (result OBJ (type . undefined)))
(sessionId . A1BD02811FD42011A5325723F2D31819))
#<WAIT-GROUP :counter 1>
Response: (OBJ (id . 3) (result OBJ (result OBJ (type . undefined)))
(sessionId . 4DC48E49A8133A13BED664D9C466F892))
#<WAIT-GROUP :counter 0>
Response: (OBJ (id . 4) (result OBJ (result OBJ (type . undefined)))
(sessionId . 4DC48E49A8133A13BED664D9C466F892))
#<WAIT-GROUP :counter -1>
Diffstat (limited to 'l/src')
-rw-r--r-- | l/src/main.lisp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/l/src/main.lisp b/l/src/main.lisp index bf16ef4..9e2c2b5 100644 --- a/l/src/main.lisp +++ b/l/src/main.lisp @@ -124,6 +124,11 @@ (defun reload-tab (session-id) ;; Use call ID "2" as this will always be sent after a `reload-extension` ;; message. + + ;; Two response messages always come back from the `chrome.tabs.reload()` + ;; messages, so we need to add a second increment to the wait group. + (wait-group:add *wg*) + (websocket-send *client* (runtime-evaluate-msg |