-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
The output is not JSON.stringify-safe #55
Comments
This package does not guarantee I think we could convert |
No, I only backport critical security issues. |
That's currently my only use case. Are there many others that don't also require JSON compatibility? How do you feel about making it a guarantee? I imagine doing so by switching through (at least) all JSON types (plus special cases like
Makes sense. How about
Would you publish a version if someone else backported it? 😅 |
Other serialization formats. I didn't want it to be too opinionated. The goal was to simplify an error to a plain object with primitive values. But I do agree
I think it depends on your use-case. Whether you need to just display the error or you want it transferred and parsed somewhere else. Your suggestion looks a little bit too close to object type output:
I get asked about this all the time. I'm not really interested in spending all my time backporting or handle backports. It's a slippery slope. If I say yes to this, I'm obliged to handle backporting of any bugs or missing use-cases with this feature. Nothing is stopping you from backporting in your own fork and using that though. You can use Git forks directly from npm. |
I think that's just as fine. Since we can't do perfect deserialization anyway, it's simply about doing something more useful than stripping the value to me.
That was actually on purpose because buffers are serialized with that style. It's not important to me though - both versions can be parsed and any version will require a positional expectation for BigInts to parse anyway.
I totally get it. I'd do the backporting. I'm asking if you would:
If we successfully land a PR here to add perfect JSON compatibility. Not because a fork wouldn't perfectly solve my problem, but because I want as many people as possible to benefit from it. |
While it seems to make sense at first, I don’t think this should be part of Calling I think serializing other types is a slippery slope before serialize-error turns into serialize-javascript |
The output is not JSON.stringify safe, see discussion in sindresorhus#55 I noticed this myself when trying to pass a [`got`](https://github.com/sindresorhus/got) error to this - it causes JSON.stringify to fail
The fix seems simple if doing something akin to buffers (though the value could be embedded). Am I missing something? If fixed by a PR, could it be backported no a non-ESM version?
The text was updated successfully, but these errors were encountered: