Skip to content

Commit edc49bc

Browse files
committed
server: Fix idle timeout to not include connect time
When --connect-timeout and idle --timeout are both 60s, and a browser takes ~60s to come online, it immediately got killed by the idle timeout because `browser.lastReceived` message was set when connecting begun and the first regular result hasn't been received yet. Make sure to give the first test 60s from when the browser comes online. Example before this fix: ``` $ node bin/qtap.js -b edge -r none -v --timeout 60 test/fixtures/pass.html 23:46:00 … 23:46:00 [qtap_main] get_browser edge 23:46:00 [qtap_server_S1] server_listening Serving /home/runner/work/qtap/qtap at http://localhost:37207 23:46:00 [qtap_browser_client_S1_C1_edge] browser_launch_call 23:46:00 … 23:46:00 [qtap_browser_client_S1_C1_edge] browser_spawn_command /usr/bin/microsoft-edge … 23:46:00 [qtap_server_S1] … 23:47:00 [qtap_browser_client_S1_C1_edge] WARNING browser_connect_timeout Browser did not start within 60s 23:47:00 [qtap_server_S1] browser_connect_retry Retrying, attempt 2 of 3 23:47:00 [qtap_browser_client_S1_C1_edge] browser_launch_call 23:47:00 [qtap_browser_client_S1_C1_edge] … 23:47:00 [qtap_browser_client_S1_C1_edge] browser_spawn_command /usr/bin/microsoft-edge … 23:47:00 [qtap_browser_client_S1_C1_edge] browser_connected Edge Headless connected! Serving test file. 23:47:00 [qtap_browser_client_S1_C1_edge] WARNING browser_idle_timeout Test timed out after 60s 23:47:00 [qtap_browser_client_S1_C1_edge] browser_launch_stopping BrowserStopSignal: Test timed out after 60s 23:47:00 … 23:47:00 __ERROR__ 23:47:00 23:47:00 Bail out from test/fixtures/pass.html in Edge Headless: 23:47:00 Test timed out after 60s ```
1 parent 3be61a7 commit edc49bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/server.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,14 @@ class ControlServer {
672672
// tapParser.on('plan', logger.debug.bind(logger, 'browser_tap_plan'));
673673

674674
browser.tapParser = tapParser;
675+
// It is valid for connectTimeout to be more or equal than idleTimeout.
676+
// These two should be treated separately and not overlapping, as otherwise
677+
// a slow launch or retried launch would eat from the first test's idleTimeout
678+
// and the browser could timeout before it begins.
679+
//
680+
// We treat 'clientonline' as the first message received from the browser,
681+
// and start counting idleTimeout only after that. .
682+
browser.lastReceived = performance.now();
675683

676684
// Optimization: The naive approach would be to clearTimeout+setTimeout on every tap line,
677685
// in `handleTap()` or `tapParser.on('line')`. But that adds significant overhead from

0 commit comments

Comments
 (0)