webdriverio icon indicating copy to clipboard operation
webdriverio copied to clipboard

WebdriverIO not acting on sessions response when connection retry timeout is longer than X minutes

Open wswebcreation opened this issue 6 years ago • 6 comments

Environment (please complete the following information):

  • WebdriverIO version: 6+
  • Mode: Testrunner
  • If WDIO Testrunner, running sync/async: sync
  • Node.js version: 12
  • NPM version: 6
  • Browser name and version: real device in Sauce Labs RDC
  • Platform name and version: Abdroid
  • Additional wdio packages used (if applicable): `@wdio/sauce-service

Config of WebdriverIO

exports.config = {
      //...
      // 15 min
      connectionRetryTimeout: 900000
      capabilities: [{
            testobject_api_key: 'XXXXXXXX',
                newCommandTimeout: 900,
                tunnelIdentifier: 'Build_135',
                name: 'Build_135',
                cacheId: 'Build_135',
                idleTimeout: 180,
                orientation: 'PORTRAIT',
                phoneOnly: true,
                tabletOnly: false,
                platformName: 'Android',
                deviceName: 'Samsung Galaxy S8',
                platformVersion: '9'
          }]
{

Describe the bug In the public Sauce Labs device cloud devices can be requested based on the above capabilities. It could take some time if a specific devices is requested because multiple users could use the device. This means the requested session needs to wait for x amount of minutes. Before the device is being released it is being cleaned and then returned to a new user for a new session. To support this feature the connectionRetryTimeout set to 15 minutes, but when the devices is returned within that 15 minutes, meaning a response is send back to WebdriverIO, it is not being picked up by WebdriverIO and times out after 15 minutes resulting in the default retry and breaks in the end.

To Reproduce please contact me for more information, but please check the logs below

Expected behavior If a response is being returned within the 15 minutes (or lower amount of minutes) it should be handled by WebdriverIO

Log I've pasted the logs of WebdriverIO and Sauce Labs here. Please see the following data

  • the session is requested from WebdrivertIO at 1:44:04
  • the session is being created in Sauce Labs at 1:53:03
  • Sauce Labs returns a response at 1:53:26
  • WebdriverIO time out at 01:59:04, this is after 15 min, but the device has been allocated after 7 minutes
  • The retries will not works after that because the device has been allocated to a different user again

This is the log from WebdriverIO

04:44:03  2020-05-13T01:44:02.456Z INFO @wdio/cli:launcher: Run onWorkerStart hook
04:44:03  2020-05-13T01:44:02.458Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js,--no-color,--baseUrl=http://172.17.0.2:9009,--sauce_user=XXXXXXXX,--sauce_key=XXXXXXXX
04:44:03  [0-0] 2020-05-13T01:44:02.687Z INFO @wdio/local-runner: Run worker command: run
04:44:03  [0-0] 2020-05-13T01:44:02.791Z DEBUG @wdio/local-runner:utils: init remote session
04:44:03  [0-0] 2020-05-13T01:44:02.793Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
04:44:05  [0-0] RUNNING in Android - /tests/visual_regression/composition_tests.ts
04:44:05  [0-0] 2020-05-13T01:44:04.165Z DEBUG @wdio/utils:initialiseServices: initialise service "image-comparison" as NPM package
04:44:05  [0-0] 2020-05-13T01:44:04.213Z DEBUG @wdio/local-runner:utils: init remote session
04:44:05  [0-0] 2020-05-13T01:44:04.214Z INFO webdriverio: Initiate new session using the webdriver protocol
04:44:05  [0-0] 2020-05-13T01:44:04.215Z INFO webdriver: [POST] https://eu1.appium.testobject.com/wd/hub/session
04:44:05  [0-0] 2020-05-13T01:44:04.215Z INFO webdriver: DATA {
04:44:05    capabilities: {
04:44:05      alwaysMatch: {
04:44:05        testobject_api_key: 'XXXXXXXX',
04:44:05        newCommandTimeout: 900,
04:44:05        tunnelIdentifier: 'Build_135',
04:44:05        name: 'Build_135',
04:44:05        cacheId: 'Build_135',
04:44:05        idleTimeout: 180,
04:44:05        orientation: 'PORTRAIT',
04:44:05        phoneOnly: true,
04:44:05        tabletOnly: false,
04:44:05        platformName: 'Android',
04:44:05        deviceName: 'Samsung Galaxy S8',
04:44:05        platformVersion: '9'
04:44:05      },
04:44:05      firstMatch: [ {} ]
04:44:05    },
04:44:05    desiredCapabilities: {
04:44:05      testobject_api_key: 'XXXXXXXX',
04:44:05      newCommandTimeout: 900,
04:44:05      tunnelIdentifier: 'Build_135',
04:44:05      name: 'Build_135',
04:44:05      cacheId: 'Build_135',
04:44:05      idleTimeout: 180,
04:44:05      orientation: 'PORTRAIT',
04:44:05      phoneOnly: true,
04:44:05      tabletOnly: false,
04:44:05      platformName: 'Android',
04:44:05      deviceName: 'Samsung Galaxy S8',
04:44:05      platformVersion: '9'
04:44:05    }
04:44:05  }
04:59:16  [0-0] 2020-05-13T01:59:04.336Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.

This is the log in Sauce Labs (truncated to remove verbose data

101:53:03 V [HTTP] --> POST /wd/hub/session
201:53:03 V [HTTP] {"desiredCapabilities":{"orientation":"PORTRAIT","testobject_platform_name":"Android","testobject_test_name":"Build_135","testobject_device":"Samsung Galaxy S8","usedCachedDevice":false,"deviceName":"Samsung_Galaxy_S8_real","cacheId":"Build_135","testobject_tablet_only":false,"tunnelIdentifier":"Build_135","newCommandTimeout":900,"idleTimeout":180,"name":"Build_135","browserName":"Chrome","testobject_api_key":"XXXXXXXX","chromeOptions":{"w3c":false},"platformName":"Android","testobject_phone_only":true}}
301:53:03 V [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"orientation":"PORTRAIT","testobject_platform_name":"Android","testobject_test_name":"Build_135","testobject_device":"Samsung Galaxy S8","usedCachedDevice":false,"deviceName":"Samsung_Galaxy_S8_real","cacheId":"Build_135","testobject_tablet_only":false,"tunnelIdentifier":"Build_135","newCommandTimeout":900,"idleTimeout":180,"name":"Build_135","browserName":"Chrome","testobject_api_key":"XXXXXXXX","chromeOptions":{"w3c":false},"platformName":"Android","testobject_phone_only":true},null,null]
401:53:03 V [debug] [BaseDriver] Event 'newSessionRequested' logged at 1589334783223 (01:53:03 GMT+0000 (Coordinated Universal Time))
======================================================================
3001:53:03 V [Appium] 
3101:53:03 V [Appium] Appium v1.14.0 creating new AndroidUiautomator2Driver (v1.33.1) session
======================================================================
30001:53:26 V [debug] [MJSONWP (a43a6454)] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"suppressKillServer":true,"chromedriverPorts":[[26270,26280]],"chromedriverChromeMappingFile":"/root/.testobject_devices/work/chromedriver-mapping.json","adbPort":15027,"chromedriverExecutableDir":"/root/.testobject_devices/work/chromedrivers","systemPort":8227,"orientation":"PORTRAIT","testobject_platform_name":"Android","testobject_test_name":"Build_135","testobject_device":"Samsung Galaxy S8","usedCachedDevice":false,"deviceName":"Samsung_Galaxy_S8_real","cacheId":"Build_135","testobject_tablet_only":false,"tunnelIdentifier":"Build_135","newCommandTimeout":900,"idleTimeout":180,"name":"Build_135","browserName":"Chrome","testobject_api_key":"B79FCA02CF804F7187AB7FC86692F2AC","chromeOptions":{"w3c":false},"platformName":"Android","testobject_phone_only":true},"suppressKillServer":true,"chromedriverPorts...
30101:53:26 V [HTTP] <-- POST /wd/hub/session 200 23493 ms - 2186
30201:53:26 V [HTTP]

wswebcreation avatar May 18 '20 06:05 wswebcreation

@wswebcreation do you still experience these issues with users that you interact with?

christian-bromann avatar Sep 15 '20 08:09 christian-bromann

I've experienced this issue just yesterday on Sauce Labs, using webdriver io 6.4.7, using Sauce Labs legacy RDC

IevgenRagulin avatar Sep 30 '20 22:09 IevgenRagulin

@IevgenRagulin thanks for confirming. We are working on a protocol change that will allow async session creation.

christian-bromann avatar Oct 01 '20 08:10 christian-bromann

In the meantime, do you perhaps know what is that X value after which webdriverio ignores that device once it become available? Currently we have things configured to wait up to 10 minutes to wait for the device, and sometimes we are getting bitten by this issue. Perhaps setting it to 5 minutes would help?

IevgenRagulin avatar Oct 01 '20 16:10 IevgenRagulin

Any progress on this issue?

marklynk avatar Jan 26 '21 22:01 marklynk

Closing this one due to the fact that Sauce real devices moved to a new set up. I'm not experiencing this anymore. Feel free to open a new issue with all needed logs if someone else experiences this issue again

wswebcreation avatar Nov 22 '21 16:11 wswebcreation