-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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: better tracking of seen objects in error serialization #5032
Conversation
Breaks circular references in before objects are serialized to prevent cryptic error in parallel mode.
Worth a re-run of the failing test? |
@Uzlopak looks like it might be a false positive. Windows tests ok for v14/v18 and i can't think of anything that might be low-level enough to affect just that set of versions. |
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.
LGTM, nice and clean! ✨
@voxpelli I know you were looking at errors too, so I'd want to defer to your review on this one too.
FWIW @sam-super you don't need to keep merging in I just wanted to wait a bit for a second review in case Pelle had time. That was time boxed till end of last week, so I'll go ahead and merge + release this now. Thanks again for the PR! 🙌 |
Published in |
Hello @sam-super @JoshuaKGoldberg, I have received the following exception randomly since this release. Do you know if it could be related to the change? 🤔
Regards, |
Ah looks like it was! #5170 cc @sam-super |
Description of the Change
Breaks circular references in before objects are serialized to prevent cryptic errors in parallel mode.
E.g. (taken from the linked issue):
For context we have seen this sort of error when using nestjs (e.g. when a module is missing a dependency, the error thrown contains a circular reference). It's likely something that would be good to fix in nestjs, but mocha would ideally handle it gracefully, regardless.
Alternate Designs
We could just strip all 'extra' props of the Error object and keep only the standard parts (e.g.
message
,name
andstack
). Would need to make sure those props are what we expectthem to be. This would be more performant but at the cost of losing useful information on the error object.Why should this be in core?
Saves people from having to turn parallel mode off to work out why their test failed.
Benefits
Errors that contain circular references can be more easily debugged.
Possible Drawbacks
There is probably a performance penalty when inspecting the objects. The assumption is that it's not prohibitive.
Applicable issues
This will be a fix/patch release
Fixes #4552