-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: Deal with new W3C spec Error response #10974
fix: Deal with new W3C spec Error response #10974
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a test for this to avoid future regressions?
b92f353
to
9878ff5
Compare
@christian-bromann There is an issue in linux only, you aware of what might be the cause? /home/runner/work/webdriverio/webdriverio/packages/wdio-reporter/cjs/utils.js:7
const supports_color_1 = __importDefault(require("supports-color"));
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/webdriverio/webdriverio/packages/wdio-reporter/node_modules/supports-color/index.js from /home/runner/work/webdriverio/webdriverio/packages/wdio-reporter/cjs/utils.js not supported.
Instead change the require of index.js in /home/runner/work/webdriverio/webdriverio/packages/wdio-reporter/cjs/utils.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/runner/work/webdriverio/webdriverio/packages/wdio-reporter/cjs/utils.js:7:42)
at Object.<anonymous> (/home/runner/work/webdriverio/webdriverio/packages/wdio-reporter/cjs/index.js:9:20)
at Object.<anonymous> (/home/runner/work/webdriverio/webdriverio/e2e/interop/wdio-reporter.e2e.js:2:22) {
code: 'ERR_REQUIRE_ESM'
} |
I am aware and we are working on fixing it. I will rebase your PR once we have a green build again. |
9878ff5
to
57a0e5d
Compare
0437f0a
to
b674c86
Compare
5463dfc
to
bb1c2e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still would love to have a script to reproduce it to validate whether this fix is the best approach to resolve the original problem.
@@ -109,7 +129,7 @@ export const getElements = function getElements( | |||
...getWDIOPrototype('element') | |||
} | |||
|
|||
const elements = elemResponse.map((res: ElementReference | Element | Error, i) => { | |||
const elements = [elemResponse].flat(1).map((res: ElementReference | Element | Error | ChromedriverErrorResponse, i) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nextlevelbeard I didn't know this was changed so I love that you created this PR, I got some feedback which I feel might sound harsch but it's very objectively so nothing personal :)
I feel like there is no need for the ChromedriverError class, using the Error class suffices as the ChromedriverError aims to change take the message to either error, name or an empty string. Which should not be part of the class but should be the input (aka the message) and the rest works like it normally would.
However! I do see you use stacktrace
instead of stack
and if this is changed in Chromedriver, we shouldn't change how we handle this, instead we should report that stacktrace
isn't a valid property name for the stacktrace (stack
is) of an Error https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @erwinheitzman thanks for having a look at this
As Christian mentioned ChromeDriver is throwing an Error that deviates from a standard Error because it is respecting the W3C spec. I believe it is in the interest of the project to fix this bug but also define this new Error type, give it a proper interface and have it inherit the Error class so that it can be understood/handled as any other error across the code base. At least that's my understanding. We are basically creating a standard error class by mapping the stacktrace
to stack
, error
to name
, and keeping the message
property.
@nextlevelbeard anything we can do to help get this over the line? |
@christian-bromann Just needs a bit of a refactor on the Error and finalize the tests. |
bb1c2e6
to
e53735d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, lgtm 👍
Proposed changes
Fixes #10843
Deal with new Chrome error responses to find element request.
Sometimes Chrome response is an error object like
instead of an array of elements that we have expected so far.
This change warps the element response in an array but then flats it till depth 1, meaning it maintains previous logic for an element response array but also wraps this new error object in an array. It will then be handled normally as other errors are, instead of crashing the test-runner with
Types of changes
Checklist
Further comments
Reviewers: @webdriverio/project-committers