-
Notifications
You must be signed in to change notification settings - Fork 253
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
feat: make circular input errors for EJSON expressive #433
Conversation
Give errors roughly in the style of those thrown by `JSON.stringify()` on modern Node.js/V8 versions, where the path to the property and its circularity are visualized instead of just recursive indefinitely. This is just one suggested solution – it would be nice to have *some* kind of better error in these cases, and I think actually displaying the path would be nice in terms of UX, but I can also see an argument for avoiding the extra bits of complexity here. NODE-3226
As always thanks for helping us improve our BSON lib it is much appreciated, here's some thoughts I came across while testing this locally:
Here's the little example I was playing around with, I think the blank space between the two arrows before I am thinking it is difficult enough to build this path correctly that it warrants a separate PR / project to ensure we can get it right. Meanwhile I think it would be great to merge in the circular detection logic to avoid the "Max Stack" error that currently occurs. Is there potentially an alternative here where we use |
Yes, that’s true.
I don’t really think so, tbh – yes, there were off-by-one errors here, and it’s fair to say that not adding more extensive tests for those situations was not great, but this isn’t exactly rocket science either. I’ve fixed this and added the tests, but of course that doesn’t mean that this can’t still be split out into a separate PR, especially if this helps get the baseline check released a bit faster.
Yeah, that’s okay – if you want me to do that, just be explicit about it. :)
To be honest, I feel like that using |
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.
off-by-one errors here
Ah now that I see the fix I agree it was a small thing, thanks for adding those tests.
To be honest, I feel like that using
util.inspect
output as-is would be way too verbose
I think that is fair, and given my revision on how difficult I thought this was I don't think we need to change the format it is helpful as is (sans one small optional nit).
Co-authored-by: Neal Beeken <neal.beeken@mongodb.com>
Give errors roughly in the style of those thrown by
JSON.stringify()
on modern Node.js/V8 versions, where the path tothe property and its circularity are visualized instead of just
recursive indefinitely.
(See the test file for an example of how that would look like)
This is just one suggested solution – it would be nice to have some
kind of better error in these cases, and I think actually displaying
the path would be nice in terms of UX, but I can also see an argument
for avoiding the extra bits of complexity here.
NODE-3226
Description
What changed?