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

[🐛 Bug]: Wrong uncaught exception handing produces "process is not defined" error #831

Closed
3 tasks done
YakovL opened this issue Aug 15, 2023 · 3 comments
Closed
3 tasks done
Labels
bug 🐛 Something isn't working needs triaging ⏳

Comments

@YakovL
Copy link
Contributor

YakovL commented Aug 15, 2023

  • 🔎 I have made sure that my issue is not a duplicate.
  • 🧪 I have made sure that my issue still exists on latest version of Synpress.
  • 💡 I can provide enough details to reproduce my issue on local environment.

Environment

  • Synpress version: 3.7.1
  • Node.js version: 18.16.0
  • Operating system: Windows 10 Pro x64
  • Run mode: Cypress + Synpress (as plugin)
  • CI platform: none
  • Are you running your tests inside docker? No, I'm not using docker, so this issue is not related to it.

What happened?

After suffering the poorly reproducible ReferenceError: process is not defined problems here and there, I've finally found the culprit.

The thing seems to be, the Synpress tries to retrieve the FAIL_ON_ERROR variable on frontend:

  1. Its only usages are here and here in support/index.js;
  2. Through analysing the sources in Dev Tools (*), I've found that one process is not defined error that had bothered me without any particular problem source were from a line containing process.env.FAIL_ON_ERROR. I've found the fragments referenced above, commented out lines 8 and 10 – and the problem was gone! (I won't be able to reconstruct that particular problem in a reproducible way and with a small piece of code, so I'm just describing the way I've researched it).
  3. On another step of my long scenario for a complex app, I've got problems with confirmMetamaskPermisionToApproveAll, and commenting out 17-19 in the file above fixed that, too! Well, not fixed exactly: instead, I've got helpful error messages that are to be handled separately.
  4. Finally, I've moved to the well-known problem with the watch mode and found that now I'm getting other, more helpful errors in the watch mode (again, to be researched separately).

(*) to be able to do that, I'm using this:

afterEach(function () {
  if (this.currentTest?.state === 'failed') {
    cy.pause();
  }
});

so that the browser is not closed once the failure happens.

What is your expected behavior?

I've expected no such process is not defined errors in the first place. At times they are not reproducible (that's not a surprise as basically any frontend exception is converted into this non-informative process is not defined) and they complicate debugging tremendously

How to reproduce the bug

The easiest way to reproduce this is to use cypress open (again, see here)

PS

I'm not sure why this got to production, as the whole FAIL_ON_ERROR feature doesn't work. To check: any autotests for it? In what environments could it still work?

I'm not creating a PR since I don't know the history of the feature and the hack of commenting those bits out doesn't look like a proper solution. @drptbl git blame suggests that it was you who introduced that issue, do you remember any context?

@YakovL
Copy link
Contributor Author

YakovL commented Aug 16, 2023

Ah, presumably Cypress.env should be used instead of process here. Once I test this, I'll create a PR

@YakovL
Copy link
Contributor Author

YakovL commented Aug 17, 2023

Alright, I've tested the fix, found that it helps, and created a PR, hope it will get merged!

@r3kt-eth
Copy link
Contributor

thank you for reporting and fixing 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working needs triaging ⏳
Projects
None yet
Development

No branches or pull requests

2 participants