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

an uncaught exception after clearing the local storage #1222

Open
kalcefer opened this issue Jan 16, 2025 · 11 comments
Open

an uncaught exception after clearing the local storage #1222

kalcefer opened this issue Jan 16, 2025 · 11 comments
Assignees
Labels
theme:cypress type:bug Something isn't working

Comments

@kalcefer
Copy link

Describe the bug
an uncaught exception after clearing the local storage. And the test freezes.
(uncaught exception) SecurityError: Failed to enumerate the properties of 'Storage': Access is denied for this document.

To Reproduce
cy.visit(http://${Cypress.env("host")})
cy.clearLocalStorage()
cy.reload()
or
cy.visit(http://${Cypress.env("host")})

Expected behavior
the test should end as passed or failed

Screenshots

Image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser chrome 131
  • cypress 13.17
  • allure-cypress 3.0.9
  • allure-commandline 2.32.0

Additional context

I observe this behavior both in open mode and in run mode. If disabled in e2e.js import "allure-cypress"; Then the test passes successfully. At the same time, reports are not even used in the test. I've checked versions from 3.0.1 to 3.09. I see this behavior in each one.

@kalcefer
Copy link
Author

exception handling does not help, but only hides the error.
Cypress.on("uncaught:exception", (err, runnable) => { return false; });

@kalcefer
Copy link
Author

To localize the error, I created a clean project. which includes only

"allure-commandline": "2.32.0",
"allure-cypress": "3.0.9",
"cypress": "13.17.0",

I did only one test consisting of the minimum number of steps.

it("test2", () => {
    cy.visit("http://${url}");
    cy.wait(2000);
    cy.clearLocalStorage();
    cy.wait(2000);    
    cy.reload();   
  });

cypress.config.js ==>

const { defineConfig } = require("cypress");
const { allureCypress } = require("allure-cypress/reporter");

module.exports = defineConfig({
  viewportWidth: 1920,
  viewportHeight: 1080,
  responseTimeout: 20000,
  defaultCommandTimeout: 20000,
  chromeWebSecurity: false,
  video: true,
  e2e: {
    specPattern: "cypress/test/*.spec.{js,jsx,ts,tsx}",
    setupNodeEvents(on, config) {
      allureCypress(on, config, {
        resultsDir: "./allure-results",
        videoOnFailOnly: true,
      });
      return config;
    },
  },
});

I've tested this in chromium-like browsers, and an error occurs in all of them. The test does not complete after the error.

Image

If I turn off allure in the entire project. Then this error does not occur.

@epszaw epszaw self-assigned this Jan 24, 2025
@epszaw
Copy link
Member

epszaw commented Jan 24, 2025

Hey there, @kalcefer! I'd tried to reproduce the problem, but I didn't reproduce the problem.

Image

I created an example repository with almost the same code, could you check it out?

@kalcefer
Copy link
Author

I created an example repository with almost the same code, could you check it out?

I checked on your repository. You really can't play it. But if you add a page refresh at the end. cy.reload(), the error immediately appears.

it("sample test", () => {
  cy.visit("/");
  cy.log("before");
  cy.wait(200);
  cy.clearLocalStorage();
  cy.wait(200);
  cy.reload();
  cy.log("after");
});

Image

PS
The case I'm checking:

  1. I go to the web application
  2. I change the settings of the web application
  3. The web application saves them to the browser's local storage
  4. I reload the page without the cache to make sure that the settings are deducted from the local storage
  5. clearing the local storage
  6. I reload the page to make sure that the settings are erased

@epszaw
Copy link
Member

epszaw commented Jan 27, 2025

Yes, adding the page reload breaks the flow. Thank you for the clarifying 👍

@epszaw
Copy link
Member

epszaw commented Jan 27, 2025

So, I disabled allure reporter in the project and I still observe the error.

Image

This is the config content:

Image

@kalcefer
Copy link
Author

@epszaw
please comment on the line. That will be enough.

// import "allure-cypress"

in the file /support/e2e.js

@epszaw
Copy link
Member

epszaw commented Jan 27, 2025

@epszaw please comment on the line. That will be enough.

// import "allure-cypress"

in the file /support/e2e.js

Correct. Thank you again, working on that 👌

@epszaw epszaw mentioned this issue Jan 27, 2025
2 tasks
@epszaw
Copy link
Member

epszaw commented Jan 29, 2025

The problem was solved, and the fix will be available in the next release 🙏

@kalcefer
Copy link
Author

Thanks, I'll check the new version and Close issue

@baev
Copy link
Member

baev commented Jan 30, 2025

@kalcefer, the fix is released in 3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:cypress type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants