Commit 8b18549
committed
build: Fix duplicate "browser_connected" debug log message
When there is a retry after a timeout, the final "browser_connected"
debug message was logged multiple times.
Example:
```
05:30:49 [qtap_browser_client_S1_C1_edge] browser_spawn_command /usr/bin/microsoft-edge …
05:31:49 [qtap_browser_client_S1_C1_edge] WARNING browser_connect_timeout Browser did not start within 60s
05:31:49 qtap_server_S1] browser_connect_retry Retrying, attempt 2 of 3
05:31:49 [qtap_browser_client_S1_C1_edge] browser_spawn_command /usr/bin/microsoft-edge
05:31:49 [qtap_browser_client_S1_C1_edge] browser_launch_stopped BrowserConnectTimeout: Browser did not start within 60s
05:31:49 [qtap_browser_client_S1_C1_edge] browser_connected Edge Headless connected! Serving test file.
05:31:49 [qtap_browser_client_S1_C1_edge] browser_connected Edge Headless connected! Serving test file.
05:31:49 [qtap_browser_client_S1_C1_edge] WARNING browser_idle_timeout Test timed out after 60s
```
This happened because the first attempt was still listening to the `clientonline`
event and handling the later attempt to send its own copy of the log message
just before calling `resolve()` on the already-rejected Promise.
That resolve() call is a no-op, but logger call is not.
We could fix this by carefully avoiding that through local state, such as by
setting `connectTimeoutTimer = false` from the setTimeout callback and checking
that in the 'clientonline' callback. Or, by adding support for `eventbus.off()`
and removing the 'clientonline' callback from inside setTimeout callback.
This patch does none of that, and instead leverages the fact that the Promise
boundary already cleanly represents this, by moving the log message to the
caller.1 parent edc49bc commit 8b18549
1 file changed
+2
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| 447 | + | |
447 | 448 | | |
448 | 449 | | |
449 | 450 | | |
| |||
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
541 | | - | |
542 | | - | |
543 | | - | |
| 542 | + | |
544 | 543 | | |
545 | 544 | | |
546 | 545 | | |
| |||
574 | 573 | | |
575 | 574 | | |
576 | 575 | | |
577 | | - | |
578 | 576 | | |
579 | 577 | | |
580 | 578 | | |
| |||
0 commit comments