Open xxluke opened 8 months ago
facing same issue
Experiencing the same issue when trying to login in our app with Keycloak
We are seeing the same issue as well. Some of our tests end with asserting that the page redirection (to another origin) worked. Then when the next test runs, we get this error intermittently.
TypeError: Cannot read properties of null (reading 'postMessage')
We're also have been experiencing same issues with 'postMessage' exception being thrown
In our case listening for uncaught exceptions inside cy.origin stopped Cypress from running into the postMessage
issue:
cy.origin(Cypress.env('app_url'), () => {
cy.on('uncaught:exception', (e) => {
console.log(e);
return false;
});
});
So I had a similar issue but with our cy.visit()
method. Up until recently we had had routes such as cy.visit('logout')
or cy.visit('login')
. After a minor upgrade to 13.4.0 (and an upgrade of Node 16 to 20), these methods began throwing the same errors that OP was receiving. Our solution was to just include leading forward slashes in our visit param i/e cy.visit('/login')
This doesn't solve OPs issue, but may help someone struggling with this error.
We also have this issue. It's with only 1 very specific test.
The weirdest thing is that it seems like it started randomly. No code changes on the repo, same versions of Node (18.19), Cypress(12.17) and Chrome (120) used.
We also have this issue. It's with only 1 very specific test.
The weirdest thing is that it seems like it started randomly. No code changes on the repo, same versions of Node (18.19), Cypress(12.17) and Chrome (120) used.
Exact same issue here, Cypress 12.17, node 18.12. 1 specific test started failing suddenly without changes. Running the test in isolation passes without problems.
We also have had this problem recently...
I ran into the same problem today. Do we know what does the "postMessage" even do? Is it important? Is the workaround mentioned viable?
@mcmartincerny My issue was clicking a link that opened a different origin(A different url than cypress). I fixed it by preventing such behavior
I was using this: cy.visit('/...') So changing the origin will mean you can't visit the same docs for your app
Current behavior
I get this error in about half of all attempts:
In console:
While Cypress states that the "error originated from your application code, not from Cypress", it actually does originate from Cypress, here:![grafik](https://github.com/cypress-io/cypress/assets/8194761/51df913b-b8be-45e2-bd7b-203de19aaff4)
Desired behavior
There should be no error. Also it's misleading that the UI says the error doesn't originate from Cypress when it does.
Test code to reproduce
I couldn't make a reproduction in time and I don't want to publish my company's internal url. However, the test code is very simple:
As you can see on my first screenshot, a XHR request of the first website is still marked as pending, so I guess the ending event was the one that couldn't get through anymore.
Cypress Version
13.6.2
Node version
v18.17.0
Operating System
Windows 11 22H2
Debug Logs
No response
Other
As a workaround, a global event listener seems to work: