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

fix: log error on reject with string content #25059

Merged
merged 6 commits into from
Dec 19, 2022

Conversation

geritol
Copy link
Contributor

@geritol geritol commented Dec 8, 2022

User facing changelog

Fixes issue where unhadled promise rejectection was being logged as (uncaught exception) undefined: undefined

Additional details

Change was needed to help debugging failures where user has only access to cy console output.

Steps to test

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 8, 2022

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2022

CLA assistant check
All committers have signed the CLA.

@cypress
Copy link

cypress bot commented Dec 8, 2022



Test summary

24869 1 2489 0Flakiness 25


Run details

Project cypress
Status Failed
Commit ab033fa
Started Dec 8, 2022 10:39 AM
Ended Dec 8, 2022 10:57 AM
Duration 18:28 💡
OS Linux Debian -
Browser Multiple

View run in Cypress Dashboard ➡️


Failures

cypress/e2e/cypress-in-cypress-run-mode.cy.ts Failed
1 Cypress In Cypress - run mode > hides reporter when NO_COMMAND_LOG is set in run mode

Flakiness

cookie_behavior.cy.ts Flakiness
1 ... > same site / cross origin > XMLHttpRequest > sets cookie on same-site request if withCredentials is true, and attaches to same-site request if withCredentials is true
2 ... > same site / cross origin > fetch > sets same-site cookies if "include" credentials option is specified from request, but does not attach same-site cookies to request by default (same-origin)
3 ... > same site / cross origin > XMLHttpRequest > sets cookie on same-site request if withCredentials is true, and attaches to same-site request if withCredentials is true
4 ... > same site / cross origin > fetch > sets same-site cookies if "include" credentials option is specified from request, but does not attach same-site cookies to request by default (same-origin)
cookie_login.cy.ts Flakiness
1 ... > past Max-Age, before Expires -> not logged in
This comment includes only the first 5 flaky tests. See all 25 flaky tests in the Cypress Dashboard.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@chrisbreiding chrisbreiding left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! The tests you added look good, but could you also add a test in this file? That will give us better e2e coverage of this.

Those tests are a little unusual because they run Cypress within Cypress. The tests in here are the outer tests that verify the results of the inner tests. This file has the inner tests and looks more like a standard Cypress spec. You can follow the pattern of the spec unhandled rejection test. The tests can be run locally by running yarn cypress:open within packages/app.

The only trick to writing the test is that the first argument passed to verify in the outer test (e.g. verify('spec unhandled rejection', { ... })) needs to match the name of the test in the inner test (e.g. it('spec unhandled rejection', ...)).

packages/driver/src/cypress/error_utils.ts Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_utils.ts Outdated Show resolved Hide resolved
packages/driver/src/cypress/error_utils.ts Outdated Show resolved Hide resolved
packages/driver/cypress/e2e/cypress/error_utils.cy.ts Outdated Show resolved Hide resolved
@geritol
Copy link
Contributor Author

geritol commented Dec 9, 2022

@chrisbreiding tried to add the test you mentioned, bumped into two issues which I need help on:

  1. I cannot commit unner-specs/cypress/e2e/errors/uncaught.cy.js eslint precommit hook fails:
✖ eslint --fix:

/Users/geritol/work/cypress/system-tests/project-fixtures/runner-specs/cypress/e2e/errors/uncaught.cy.js
   5:5  error  'cy' is not defined  no-undef
   6:5  error  'cy' is not defined  no-undef
  10:5  error  'cy' is not defined  no-undef
  11:5  error  'cy' is not defined  no-undef
  15:5  error  'cy' is not defined  no-undef
  16:5  error  'cy' is not defined  no-undef
  20:5  error  'cy' is not defined  no-undef
  21:5  error  'cy' is not defined  no-undef
  22:5  error  'cy' is not defined  no-undef
  26:5  error  'cy' is not defined  no-undef
  27:5  error  'cy' is not defined  no-undef
  28:5  error  'cy' is not defined  no-undef
  35:5  error  'cy' is not defined  no-undef
  39:5  error  'cy' is not defined  no-undef
  40:5  error  'cy' is not defined  no-undef
  48:5  error  'cy' is not defined  no-undef
  61:5  error  'cy' is not defined  no-undef
  67:5  error  'cy' is not defined  no-undef
  78:5  error  'cy' is not defined  no-undef

✖ 19 problems (19 errors, 0 warnings)
  1. Tests fails because it seems It is expected for the error to be printed in an other place too aside from being loggeg (after the >)

kép

Not sure where the logic of that is, maybe we need to add this transformation to a higher level in the code?

@geritol geritol requested review from chrisbreiding and removed request for ZachJW34 December 9, 2022 10:01
@chrisbreiding
Copy link
Contributor

  1. I cannot commit unner-specs/cypress/e2e/errors/uncaught.cy.js eslint precommit hook fails:

Sorry about that. Seems to be an oversight with our eslint configuration. I should have that fixed in #25089, so once it's merged, you can update from origin/develop and it will unblock you.

  1. Tests fails because it seems It is expected for the error to be printed in an other place too aside from being loggeg (after the >)

Not sure where the logic of that is, maybe we need to add this transformation to a higher level in the code?

Great. Looks like the test is doing its job because we do want the error to show up there as well.

You're right about needing to move the transformation higher. I think this is where we should do it. If it ensures that the originalErr and err properties returned are errors or at least error-like objects, the rest should work, including the logging.

@chrisbreiding
Copy link
Contributor

The eslint issue is fixed in origin/develop, so you should be able to modify and commit changes to that spec file now.

@geritol
Copy link
Contributor Author

geritol commented Dec 15, 2022

@chrisbreiding e2e test up, now failing because of the lack of stack strace on the new error log (if I get it right)
In this case we cant really show a stack trace, since we did not reject with an instace of Error. What should we do?
kép

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Cypress prints (uncaught exception) undefined: undefined when promise rejects with a string
5 participants