-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
When accessing multiple sessions with origin I get "cannot read properties of undefined reading 'message'" on azureAD with Chrome #23937
Comments
Sorry you're encountering this issue. Do you have |
Sorry for the late response, yes I have both: |
@io-sar, could you try this on cypress 10.9.0, we recently released some stability fixes for cy.origin and i'm wondering if that has had any effect on your error message. |
@mjhenkes I have tried it. Unfortunately it is not fixed. However there is a success as now I recieve also the following message : The following error originated from your test code, not from Cypress.
> Failed to construct 'URL': Invalid URL
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test. which confirms my comment "some times the failed step is showed that has no url" |
What is the stack trace provided when that error is thrown? Anything useful? |
@mjhenkes not really... :(
|
I believe I'm also seeing this issue, though not in AD (just a Win 10 Pro local machine). Upgrading from 10.3 to 10.10 did not help. 10.10 stack:
The project uses Using the test case mentioned above, I get the following:
This was all under Node 16, if it helps. |
Hello @AtofStryker, unfortunately it is not fixed on 10.10 and I have tried to use your PR. The main problem is that this is not using the azureAD on an application level thus when you try to login it redirects you during the password phase to a different origin 'https://login.live.com'. What I would try to do (currently not too much of a time) is to either have an app behind an azure ad free account. Or, try to rework with the baseUrl starting on https://login.microsoftonline.com with all the query parameters and use origin during the 'https://login.live.com'. For the latter I am not sure if it is a valid test though. I saw also the "cy.origin() use is not currently supported in the cy.origin() callback, but is planned for a future release." message. (cool feature!!) |
@turt2live @io-sar sounds like my reproduction isn't very helpful here 😅 . I think the most critical thing here is to get a fully working reproduction, which I know is a bit difficult. Worst case, private reproduction repositories where core team members are invited is also an option. Once I can see that, I have a feeling I can determine the problem. We also do have a free azure AD account within Cypress to test these scenarios. If you give me instructions on how you set up your application/tenant with a test case, I also might be able to reproduce it on my end. |
Unfortuantely I haven't been able to come up with a smaller reproduction case, though our application's use of localStorage and IndexedDB appear to be causing problems, somehow. Removing some of the idb or localstorage code resolves the issue, at least. Is there potentially something in there which sets off a lightbulb around origins? |
@turt2live nothing off the top of my head, but I wonder if it could be something related to us trying to clear localStorage too quickly when the AUT hasn't navigated. Does it happen every single time for you or intermittently? |
Very nearly 100% of the time when we set specific keys related to authentication in our app, but only about 10-15% when not setting those keys (but the tests fail anyways). Is there a way we could quickly test the navigation timing within the context of our app? Somewhat worth noting that our CI (Linux) appears to be fine, which has concerns about platform or machine dependence. |
@turt2live @AtofStryker , I dont know if it helps, but wanted to point again that in my case the tests are failing on chrome based browsers. Runnig the tests on Firefox works well (nearly 100% of the time). I am not sure if ff works differently with the localStorage @turt2live have you tried to run your failing tests with firefox ? |
I can't get Firefox to run at all, though I've also possibly been experiencing an environmental issue this whole time. Turns out the tests run perfectly fine in a fresh Windows VM, but not on my local machine. The hunt continues... |
Right now there doesn't seem to be enough information to reproduce the problem on our end. We'll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward. You may also want to try upgrading to Cypress 10.11.0 which has a few additional fixes in Please open a new issue with a reproducible example and link to this issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide. |
Started noticing this error in a |
Same issue: cross-origin call that was working fine to Stripe Checkout with |
The issue happens when the application throws And Cypress does not seem to be expecting an EDIT: I contacted the Stripe support to report the problem from their side, but even if it ends up being resolved, I think Cypress should handle cases like this more gracefully. |
This is causing us problems in automated tests that include Stripe checkout due to them raising an undefined exception. Does this need to be raised as a new issue or will this be picked up from here since this issue is already closed? |
@michaelkay-wrisk We should probably open a new issue and refer this one, especially since this one has too many misleading details about azureAD and so on. |
Raised here #29334 |
It would be helpful to get a reproducible example. I'm trying to spin up a Stripe project we have, not sure it will duplicate with exactly what y'all are seeing. |
@jennifer-shehane I built a minimal example, it does not require Stripe, it's a CodeSandbox app that does a Then to test it in any Cypress project: Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
});
it.only("Should catch the exception", () => {
cy.visit("https://www.cypress.io/")
cy.visit("https://9p6zh4.csb.app");
cy.origin("9p6zh4.csb.app", () => {
cy.visit("/");
cy.log("Success!");
});
}); As you should see (screenshot below), CodeSandbox source: https://codesandbox.io/p/sandbox/cy-origin-uncaught-exception-9p6zh4?file=%2Fsrc%2FApp.js%3A17%2C2 Thank you for taking a look :) |
@BertrandBordage Yay! I was trying out a few different situations. I do see an uncaught 'undefined' error that is not being caught with the uncaught exception handler. I don't see this exact messaging that others seemed to be reporting:
Is there another piece of code to write to get to that error? |
@jennifer-shehane Good point. I'm not sure what causes this variant of the error. I face it in a complex project but could not isolate it yet. I can share the traceback though, which is different from the other error: cypress-1 | TypeError: Cannot set property message of which has only a getter
cypress-1 |
cypress-1 | Because this error occurred during a `after each` hook we are skipping the remaining tests in the current suite: `REDACTED`
cypress-1 | at modifyErrMsg (http://norishare.localhost/__cypress/runner/cypress_runner.js:75141:15)
cypress-1 | at Object.appendErrMsg (http://norishare.localhost/__cypress/runner/cypress_runner.js:75146:10)
cypress-1 | at Runner.<anonymous> (http://norishare.localhost/__cypress/runner/cypress_runner.js:162598:68)
cypress-1 | at Runner.emit (http://norishare.localhost/__cypress/runner/cypress_runner.js:146530:7)
cypress-1 | at Runner.fail (http://norishare.localhost/__cypress/runner/cypress_runner.js:155453:8)
cypress-1 | at Runner.fail (http://norishare.localhost/__cypress/runner/cypress_runner.js:145735:25)
cypress-1 | at Runner.failHook (http://norishare.localhost/__cypress/runner/cypress_runner.js:1554[91](REDACTED):8)
cypress-1 | at Hook.<anonymous> (http://norishare.localhost/__cypress/runner/cypress_runner.js:155565:14)
cypress-1 | at next (http://norishare.localhost/__cypress/runner/cypress_runner.js:163070:24)
cypress-1 | at http://norishare.localhost/__cypress/runner/cypress_runner.js:1630[97](REDACTED):13
cypress-1 | at tryCatcher (http://norishare.localhost/__cypress/runner/cypress_runner.js:1807:23)
cypress-1 | at Promise._settlePromiseFromHandler (http://norishare.localhost/__cypress/runner/cypress_runner.js:1519:31)
cypress-1 | at Promise._settlePromise (http://norishare.localhost/__cypress/runner/cypress_runner.js:1576:18)
cypress-1 | at Promise._settlePromise0 (http://norishare.localhost/__cypress/runner/cypress_runner.js:1621:10)
cypress-1 | at Promise._settlePromises (http://norishare.localhost/__cypress/runner/cypress_runner.js:1701:18)
cypress-1 | at Promise._fulfill (http://norishare.localhost/__cypress/runner/cypress_runner.js:1645:18)
cypress-1 | at Promise._resolveCallback (http://norishare.localhost/__cypress/runner/cypress_runner.js:1439:57)
cypress-1 | at Promise._settlePromiseFromHandler (http://norishare.localhost/__cypress/runner/cypress_runner.js:1531:17)
cypress-1 | at Promise._settlePromise (http://norishare.localhost/__cypress/runner/cypress_runner.js:1576:18)
cypress-1 | at Promise._settlePromise0 (http://norishare.localhost/__cypress/runner/cypress_runner.js:1621:10)
cypress-1 | at Promise._settlePromises (http://norishare.localhost/__cypress/runner/cypress_runner.js:1701:18)
cypress-1 | at Promise._fulfill (http://norishare.localhost/__cypress/runner/cypress_runner.js:1645:18) |
@jennifer-shehane I don't have a minimally reproducible example, but the Cypress team should have enough resources at this point to either reproduce the issue or ask questions to narrow it down. |
@jennifer-shehane I managed to reproduce this error! I could only get it with Stripe, so I isolated it with the demo checkout page from Stripe. In case the generated Stripe URL I used is not going to work in the future:
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
});
it.only("Should catch the exception", () => {
cy.visit("https://www.cypress.io/");
cy.origin("checkout.stripe.com", () => {
cy.visit("https://checkout.stripe.com/c/pay/cs_test_b1ME8Ug7h3E2qvMqgXJKiR0fQV0F5lTmRujFdpktg37k3v4cCocLmXCTO0?demoWallet=applePay&demoPolicies=false#fidkdWxOYHwnPyd1blpxYHZxWjA0TUM1Yl9GT1c0a25sZjdSa2ppakZgQzdxVz1qYk9pcUBnNTc9Z11kVnc9b0F%2FREgxfE5oQ31Dd2dGME9sQVx2Tm1wc3RyRGhPZjIwTzRLYmd3TnJDSjJMNTVJMUBtbWNMQycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPydocGlxbFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl");
cy.location("host").should("equal", "checkout.stripe.com");
cy.log("Success!");
});
}); Moving the For info, I got a reply from the Stripe support, they don't plan on fixing this error but are interested in seeing Cypress resolve this side of the problem 🤦 |
@BertrandBordage Thanks, I can reproduce. Stack trace: "TypeError: Cannot read properties of undefined (reading 'message')
at makeErrFromObj (https://checkout.stripe.com/__cypress/runner/cypress_cross_origin_runner.js:91576:30)
at errorFromProjectRejectionEvent (https://checkout.stripe.com/__cypress/runner/cypress_cross_origin_runner.js:91897:10)
at Object.errorFromUncaughtEvent (https://checkout.stripe.com/__cypress/runner/cypress_cross_origin_runner.js:91902:65)
at https://checkout.stripe.com/__cypress/runner/cypress_cross_origin_runner.js:197375:72" |
I did look into this a bit yesterday. It's not as simple of a fix as accepting Strings in this case, as it was on this line here: /~https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/error_utils.ts#L192 I can fix the message error by making a new Error if the obj is undefined on that line above, but the You can throw a debugger after this line when running the above project through Cypress locally (Instructions here to watch) and see that the /~https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/cy.ts#L898 |
@jennifer-shehane I could be wrong (I don't have time today to test it), but it seems that the error is not correctly caught due to these lines: cypress/packages/driver/src/cypress/cy.ts Lines 881 to 886 in ede4a6f
which run before the cypress/packages/driver/src/cypress/cy.ts Line 898 in ede4a6f
cypress/packages/driver/src/cypress/error_utils.ts Lines 167 to 177 in ede4a6f
In my opinion, the fix should be:
For the last 2 steps, I suggest adding this after the 2 if (typeof v !== "object" || !("message" in (v ?? {}))) {
return new Error(`${err}`); // Shows `[object Object]` for objects, find a better alternative.
} Then, since |
@jennifer-shehane - could you share an update of what's happening with this and if we can expect an official fix soon? |
Let me take another look at this and see if I can get further. |
I have #29454 opened to address this issue. It looks like after fixing our error handling the issue goes away. beforeafterIn cases where there are document rejections in it.only("Should catch the exception", () => {
cy.visit("https://www.cypress.io/");
cy.origin("checkout.stripe.com", () => {
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
});
cy.visit("https://checkout.stripe.com/c/pay/cs_test_b1ME8Ug7h3E2qvMqgXJKiR0fQV0F5lTmRujFdpktg37k3v4cCocLmXCTO0?demoWallet=applePay&demoPolicies=false#fidkdWxOYHwnPyd1blpxYHZxWjA0TUM1Yl9GT1c0a25sZjdSa2ppakZgQzdxVz1qYk9pcUBnNTc9Z11kVnc9b0F%2FREgxfE5oQ31Dd2dGME9sQVx2Tm1wc3RyRGhPZjIwTzRLYmd3TnJDSjJMNTVJMUBtbWNMQycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPydocGlxbFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl");
cy.location("host").should("equal", "checkout.stripe.com");
cy.log("Success!");
});
}); |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
I have a test that tries to login with different session_id (string, string[], object) and with the use of origin on each step, with the same login provider (Azure AD). When the tests are run on Chrome or Electron (headless/browser) after the 1st login/session for an approx 80% of the times the rest of the tests will fail (see attached error).
When I run on firefox the same tests will have lower chance of failing (approx 10% -20%)
I couldnt manage to scope the reason that it fails but it could be either the security of chrome (it is disabled) or the cookies.
Another lead is that some times the failed step is showed that has no "url" during the call of the step when I check the snapshots of the stack trace
Desired behavior
No response
Test code to reproduce
-----Login helper commands ----------
-------Spec ----------------------
Cypress Version
10.8.0
Node version
v14.17.0
Operating System
macOS 12.5.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: