-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: make the primary domain communicator a singleton per cypress instance #20653
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
Conversation
|
Thanks for taking the time to open a PR!
|
5327199 to
b047a32
Compare
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
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 |
||||||||||||||||||||||||||
…nts once in the primary and per spec bridge. Forward all message events to the respective communicator instance, if available.
87d3d95 to
0f154b6
Compare
| // currently used for tests, can be removed later | ||
| if (data?.actual) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome. will push a commit that gets rid of this!
…is no longer needed
…tance (#20653) * fix: make the primary domain communicator a singleton per cypress instance * leverage a factory to make typescript happy with their super() constructor rules * remove singleton instance from communicator and only bind message events once in the primary and per spec bridge. Forward all message events to the respective communicator instance, if available. * remove data.actual reference in primary communicator onMessage as it is no longer needed
User facing changelog
N/A
Additional details
When we reload tests, this errors tends to pop up anytime we edit tests that are dealing with errors in multi-domain. This is caused by multiple instances of the
primaryDomainCommunicatorbeing created, but rebinding the samewindow.top.addEventListener('message')on recreation. This leads to duplicatemessageevents. This was introduced in #20520 when theuserInvocationStackwas added to theprimaryDomainCommunicatorinstance here. The danglingprimaryDomainCommunicatorinstance would NOT have theuserInvocationStackset, which would fail to reify errors coming back from the other domain.The proposed fix here is to make theprimaryDomainCommunicatora singleton, so thewindow.top.addEventListener('message')is only bound once. Since the top reference should not change throughopenmode, this should work correctly.Update 3/17/22
Instead of creating a singleton, we will only bind the message handler once in the primary when global listeners are added, and once in the spec bridge on creation. This refactors the initialize methods to be onMessage handlers where message events get forwarded to whatever the current instance of the communicator exists
Currently not sure of a good way to test this yet. I was thinking of maybe adding an assertion to the rerun test, but that doesn't exactly work since the file is loaded back in.
the error before fix
after fix (rerunning consistently)
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?cypress.schema.json?