-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: unify error serialization with config and other values. Fix err.onFai… #20256
fix: unify error serialization with config and other values. Fix err.onFai… #20256
Conversation
…lti-domain tests to fail in firefox run mode
…nisitc testing of big Cypress config/env changes
…nto feature/sync-config-and-env
…nto feature/sync-config-and-env
Thanks for taking the time to open a PR!
|
8e97755
to
12b0769
Compare
Test summaryRun details
View run in Cypress Dashboard ➡️ FlakinessThis 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 |
@@ -132,7 +103,7 @@ export class SpecBridgeDomainCommunicator extends EventEmitter { | |||
|
|||
try { | |||
// We always want to make sure errors are posted, so clean it up to send. | |||
const preProcessedError = preprocessErrorForPostMessage(err) | |||
const preProcessedError = _.isError(err) ? preprocessErrorForPostMessage(err) : err |
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 becomes a problem if someone tries to throw something that is unserializable. Do we think this is a valid concern?
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.
I think it is a valid concern. In general i think we should add a basic try-catch around postMessage for any unserializable data, so we can at least send a message with an error.
It might be good to hold off on this PR until after #20247 lands. |
going to move this to draft until #20247 is merged in |
closing in favor of #20520 |
…l issues
User facing changelog
n/a
Additional details
The goal of this PR is to fix the
err.onFail
is not a function bug we are seeing while writing multi-domain unit tests, as well as unify the error serialization across domains.err.onFail
was failing due to non serializable properties being stringified back to the primary domain, causing the error to fail. Instead of trying to send non serializable values as a serialized string, we now just omit these properties before sending the error (similar to env and config). Now that we process errors in theran:domain:fn
context, we need to also account for scenarios whenthrow 'oops'
or something is thrown in the secondary that may/may not be an error object. This PR should cover this at a basic level.I would have liked to use the
structuredClone
algorithm to clone Errors where applicable, but interestingly all properties declared on the error are removed when trying to clone, either with native Chrome implementations or the ponyfill. Once the Error is sent throughpostMessage
, it loses it's prototype hierarchy and ultimately just becomes an object. Therefor, I figured the method we had to pre/post process errors how we do it now is likely preferable.How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?