fix: Cypress hangs when wrapping an object containing circular references #32917
+320
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additional details
When
cy.wrap()is called with objects containing circular references, the logging code instringifyActualcauses infinite recursion because it doesn't track visited objects. This can lead to stack overflow errors - which cause the Cypress App to completely hang.I'm not sure if this is an issue with other command logs, but this addresses the issue with logging in general, so it would resolve situations there as well.
Steps to test
yarn cypress:openHow has the user experience changed?
Before
!!!! Complete Cypress App hang when running the test
After
PR Tasks
cypress-documentation?type definitions?Note
Prevents hangs when
cy.wrap()logs objects with circular references by tracking visited objects during stringification and adds comprehensive tests; updates changelog.WeakSetinstringifyActual()/stringifyActualObj()to detect cycles and return[Circular],Object{N}, orArray[N]safely.cy.wrap()logging.cy.wrap()(packages/driver/cypress/e2e/commands/misc.cy.js).utils.stringifytests for circular/nested/multiple references and adjust expectations for arrays/objects (packages/driver/cypress/e2e/cypress/utils.cy.js).cli/CHANGELOG.mdwith bugfix entry forcy.wrap()freezing on circular references.Written by Cursor Bugbot for commit f6dc83e. This will update automatically on new commits. Configure here.