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

feat: Implement WDA restart for unexpected crashes #2531

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/commands/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export default {
if (rewroteSelector) {
this.log.info(
`Rewrote incoming selector from '${initSelector}' to ` +
`'${selector}' to match XCUI type. You should consider ` +
`updating your tests to use the new selectors directly`,
`'${selector}' to match XCUI type. You should consider ` +
`updating your tests to use the new selectors directly`,
);
}

Expand Down Expand Up @@ -122,7 +122,10 @@ export default {
els = /** @type {Element[]|undefined} */ (
await this.proxyCommand(endpoint, method, body)
);
} catch {
} catch (err) {
if (err.message && err.message.match(/socket hang up/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the regexp should be moved to a global constant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do something like SOCKET_HANG_UP_PATTERN.test(err.message) instead

throw err;
}
els = [];
}
// we succeed if we get some elements
Expand All @@ -132,6 +135,9 @@ export default {
if (err.message && err.message.match(/Condition unmet/)) {
// condition was not met setting res to empty array
els = [];
}
else if (err.message && err.message.match(/socket hang up/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how what difference this condition makes here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error message in case of socket hangups for find element commands was getting overriden by NoSuchElementError which makes it undetectable in driver.js file, hence we are trying to bubble it up as socket hang up only to be able to identify on driver.js level and trigger the restart flow

throw err;
} else {
throw err;
}
Expand Down Expand Up @@ -193,7 +199,7 @@ function rewriteMagicScrollable(mult, log = null) {
}
log?.info(
'Rewrote request for scrollable descendants to class chain ' +
`format with selector '${selector}'`,
`format with selector '${selector}'`,
);
return [strategy, selector];
}
Expand Down
6 changes: 5 additions & 1 deletion lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ const desiredCapConstraints = /** @type {const} */ ({
pageLoadStrategy: {
isString: true,
inclusionCaseInsensitive: ['none', 'eager', 'normal']
}
},
enableWdaRestart: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the capability name is too broad. I would rather use something like restartWdaOnCrash

presence: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the default setting, so not needed

isBoolean: true,
},
});

export {desiredCapConstraints, PLATFORM_NAME_IOS, PLATFORM_NAME_TVOS};
Expand Down
Loading
Loading