-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: prevent serialization issues with retries using multi-domain #20628
Conversation
…sanitizing data sent to spec bridges
Thanks for taking the time to open a PR!
|
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 |
…nto fix_multi_domain_retries
…pped are also Objects/Arrays
…s in secondary domain
return sanitizedValue | ||
// convert any nested structures as well, if objects or arrays, to literals. This is needed in the case of Proxy objects | ||
_.forEach(sanitizedValueAsLiteral as any, (value, key) => { | ||
sanitizedValueAsLiteral[key] = preprocessForSerialization(value) |
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.
we technically only have to do this for Objects/Arrays, but figured this is easier to maintain to do full recursion in which the property is just returned. This can be optimized a bit more if we find this highly important
With this PR can we enable these tests again? |
@mjhenkes going to take a look. Thank you merging the feature branch back in BTW |
ba4913a
to
9486f78
Compare
User facing changelog
N/A
Additional details
The goal of this PR is to fix intermittent retry issues with tests that utilize
switchToDomain
. Previously, we were not preprocessing any values that may/may not be serializable from the primary to the secondary withtoSpecBridge
functions. This fix processes data before putting it throughpostMessage
, which should guarantee the data is serializable. There are also updates to map nested object properties within objects to literals, as well as Arrays to make sure the structure of an object is still serializable.A symptom of this is the error
Cannot set property message of which has only a getter
, which happens when unserializable values are fed throughtest:before:run:async
to the spec bridge, which contains unserializable nested object keys. A data clone error is thrown, which has getter only propertymessage
on the base error prototype class, causing this error.reproduction of error
with PR fixes
To conserve current behavior, we want to only sanitize the data we control. User defined data that is passed into
switchToDomain
should not be sanitized, and should error as usual.The only known side effect of this PR is errors passed into
Cypress.config
are flattened to objects in the secondary, and aren't reified. This seems like an incredibly rare use case, and I am not too worried about this change.How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?