Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browserstack launcher: "WebDriver Error: Timed out waiting for asyncrhonous script" on iOS devices #2706

Open
gruhn opened this issue Apr 19, 2024 · 0 comments

Comments

@gruhn
Copy link

gruhn commented Apr 19, 2024

Bug Description

When I run tests on iOS devices (iPhone/iPad) using the Browserstack launcher AND in the web-test-runner config concurrency is set to something >1, then I get the following error:

[Browserstack] Setting up Browserstack Local proxy...

2024-04-19T12:25:59.180Z ERROR webdriver: Request failed with status 500 due to WebDriver Error: Timed out waiting for asyncrhonous script result after 0 ms
index.html:

 ❌ WebDriver Error: Timed out waiting for asyncrhonous script result after 0 ms
    WebDriver Error: Timed out waiting for asyncrhonous script result after 0 ms
        at getErrorFromResponseBody (file:///Users/niklas.gruhn/Workspace/demo-browserstack-iphone-timeout/node_modules/webdriver/build/utils.js:195:12)
        at NodeJSRequest._request (file:///Users/niklas.gruhn/Workspace/demo-browserstack-iphone-timeout/node_modules/webdriver/build/request/index.js:193:23)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Browser.wrapCommandFn (file:///Users/niklas.gruhn/Workspace/demo-browserstack-iphone-timeout/node_modules/@wdio/utils/build/shim.js:90:29)
        at async Browser.wrapCommandFn (file:///Users/niklas.gruhn/Workspace/demo-browserstack-iphone-timeout/node_modules/@wdio/utils/build/shim.js:90:29)
        at async IFrameManager.stopSession (/Users/niklas.gruhn/Workspace/demo-browserstack-iphone-timeout/node_modules/@web/test-runner-webdriver/dist/IFrameManager.js:95:29)

In the Browserstack web UI I can see that the tests were successfully executed. The error only occurs when closing the session. This is the "asynchrones script" that is timing out:

const returnValue = await this.driver.executeAsync(`
var iframe = document.getElementById("${frameId}");
var testCoverage;
try {
testCoverage = iframe.contentWindow.__coverage__;
} catch (error) {
// iframe can throw a cross-origin error if the test navigated
}
// Don't move on until the iframe has settled after unloading the page
var done = arguments[arguments.length-1];
var loaded = function() {
iframe.removeEventListener('load', loaded);
iframe.removeEventListener('error', loaded);
done({ testCoverage: testCoverage });
};
iframe.addEventListener('load', loaded);
iframe.addEventListener('error', loaded);
// set src after retrieving values to avoid the iframe from navigating away
iframe.src = "about:blank";
`);

In particular, it seems like the load event on the iframe is never fired.

To Reproduce

I setup this repository with a minimal demo. Unfortunately, Browserstack credentials are required. To reproduce: pull the repository and run:

export BROWSERSTACK_USERNAME="..."
export BROWSERSTACK_ACCESSKEY="..."
npm install
npm test

Workaround

Setting concurrency: 1 in the web-test-runner config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant