Skip to content

Conversation

@AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Mar 16, 2022

  • Closes N/A

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 primaryDomainCommunicator being created, but rebinding the same window.top.addEventListener('message') on recreation. This leads to duplicate message events. This was introduced in #20520 when the userInvocationStack was added to the primaryDomainCommunicator instance here. The dangling primaryDomainCommunicator instance would NOT have the userInvocationStack set, which would fail to reify errors coming back from the other domain.

The proposed fix here is to make the primaryDomainCommunicator a singleton, so the window.top.addEventListener('message') is only bound once. Since the top reference should not change through open mode, 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

  • 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)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 16, 2022

Thanks for taking the time to open a PR!

@AtofStryker AtofStryker changed the title make the primary domain communicator a singleton per cypress instance fix: make the primary domain communicator a singleton per cypress instance Mar 16, 2022
@AtofStryker AtofStryker force-pushed the fix_reify_error_issues branch from 5327199 to b047a32 Compare March 16, 2022 20:21
@cypress
Copy link

cypress bot commented Mar 16, 2022



Test summary

4689 0 71 1Flakiness 1


Run details

Project cypress
Status Passed
Commit 08925b7
Started Mar 18, 2022 8:25 PM
Ended Mar 18, 2022 8:39 PM
Duration 14:11 💡
OS Linux Debian - 10.10
Browser Electron 94

View run in Cypress Dashboard ➡️


Flakiness

cypress/integration/commands/actions/click_spec.js Flakiness
1 shadow dom > does not fail actionability check when element is covered by its shadow host

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

@AtofStryker AtofStryker marked this pull request as ready for review March 16, 2022 21:12
@AtofStryker AtofStryker requested a review from a team as a code owner March 16, 2022 21:12
@AtofStryker AtofStryker removed the request for review from a team March 16, 2022 21:19
…nts once in the primary and per spec bridge. Forward all message events to the respective communicator instance, if available.
@AtofStryker AtofStryker force-pushed the fix_reify_error_issues branch from 87d3d95 to 0f154b6 Compare March 17, 2022 16:23
Comment on lines 32 to 33
// currently used for tests, can be removed later
if (data?.actual) return
Copy link
Contributor

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.

Copy link
Contributor Author

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!

@AtofStryker AtofStryker merged commit 432b3d5 into feature-multidomain Mar 18, 2022
@AtofStryker AtofStryker deleted the fix_reify_error_issues branch March 18, 2022 20:37
mschile pushed a commit that referenced this pull request Mar 22, 2022
…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
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.

5 participants